How to Quickly Deploy a WordPress on an Ubuntu Server

June 27, 2005
How to Quickly Deploy a WordPress on an Ubuntu Server

WordPress is the most popular content management system (CMS) on the market, powering 65.2% of websites which translates to 42.4% of all websites. It is one of the most user-friendly CMS around. Today we will show you how to deploy WordPress on an Ubuntu .

Step 1 . Creating the Server

Fast  loading speeds are important for all websites

Then choose the server config. For our site we will use a virtual server with 2 , 4 GB of , 60 GB hard drive and 50Mb/s internet connection speed. This configuration will be enough for about 50,000 users per day, which is almost an unattainable dream for a newly deployed website in the first few months. If the number of users increases, you can easily add resources to your server. For this feature, is very good at the initial stage.

We choose the “login and password” authentication and log in to our server by using putty.

Setting up the

Before installing WordPress, we need to install a package of server software — the Apache web server and the MySQL database, as well as the language. But before that, we need to update our OS:

sudo apt-get update && sudo apt-get upgrade -y

Installing Apache Web Server

In order to install the latest version of the Apache webserver, enter the following commands:

sudo apt install apache2 apache2-utils

Then add Apache to the autorun and start the service:

sudo systemctl enable apache2

sudo systemctl start apache2

To check if Apache is available online, let's type in the IP address of your server in your browser. If you are installing a webserver on a local machine, use the address or http://localhost

By default, all documents are located in the /var/www/html directory. We also require the Apache "mod_rewrite" module for WordPress to work correctly. To enable it, run the following command:

sudo a2enmod rewrite

Then restart the webserver:

sudo systemctl restart apache2

Installing the MySQL Database

To install the mysql db, run the command:

sudo apt install mysql-client mysql-server

To complete the setup, run the command:

sudo mysql_secure_installation

The system will prompt you to install a password verification plugin, which will prohibit the use of weak passwords:

Then you will need to change the password and disable access to the superuser account from the network and also disable guest access. So we answer y for all.

Installing PHP

And finally, before you install WordPress on Ubuntu 20.04 — you require installing PHP and a few modules to work with the web server and MySQL database. To do this, run the command:

sudo apt install php7.4 php7.4-mysql libapache2-mod-php7.4 php7.4-cli php7.4-cgi php7.4-gd

To test how PHP works, create a file named test.php in /var/www/html/:

sudo nano /var/www/html/test.php

File text:


Save it and then open http://ip-address/test.php in a web browser. If everything is set up correctly, you will see a page with information about the PHP version. Naturally, as a matter of security, it should be removed after a successful test.

Installing WordPress on the Ubuntu Server

So finally download the latest version of CMS WordPress from the official website:

wget -c

Extract the contents of the archive to your current folder:

tar -xzvf latest.tar.gz

Copy the WordPress files from your current folder to /var/www/html/:

sudo rsync -av wordpress/* /var/www/html/

In order for the web server to work properly with these files, you need to set the correct permissions for them, namely the user and group www-data:

sudo chown -R www-data:www-data /var/www/html/

sudo chmod -R 755 /var/www/html/

And now the installation of WordPress on Ubuntu 20.04 is complete, but there is still left to configure the database connection. To have WordPress open by default, let's delete the index.html file:

sudo rm /var/www/html/index.html

Creating a Database for the New Website

To create a database, first log in to the mysql management interface, to do so, execute:

sudo mysql -u root -p

Enter the password that you entered during installation, then separately execute the following commands to create the database, user and set the correct privileges for them:

mysql> CREATE DATABASE wp_db;

mysql> CREATE USER 'wpusr'@'localhost' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON wp_db.* TO 'wpusr'@'localhost';


mysql> EXIT;

Replace wp_db with the desired database name, wpusr with the username, and password with the desired password. The modifier localhost means that you can connect to the database only from local machine.

Configuring WordPress on the Ubuntu Server

Everything is ready to configure WordPress. Type in the ip address of your server where you installed WordPress, or localhost if the paltform was installed on a local computer. In the first window, the program will ask you to choose a language. Then click "Next" and enter the database name, username, and password that you used during db creation.

Finally, all that's left is to choose a website name, an admin login, and come up with a complex password.

At the end, all that's left is to log in, and you can use the WordPress content management system you've just set up.

Congratulations, now you can easily create your own website using a bunch of templates, plugins and a graphical interface. This is where the fun part begins.

Related Posts