How to Install WordPress 5.2.3 on Ubuntu with Apache2, MariaDB and PHP 7.2

Here is how you can install WordPress 5.2.3 on Ubuntu. In particular on Vultr’s instance i.e. Ubuntu 16.04 LTS / 18.04 LTS / 18.10.

Prerequisites

To get started with the installation of WordPress, follow the steps below:

Step 1: Create WordPress Database

To logon to MariaDB database server, run the following commands:

sudo mysql -u root -p

Then create a database called yourname_live

CREATE DATABASE yourname_live; 

Now create a database user called yourname_live_user with a new password

CREATE USER 'yourname_live_user'@'localhost' IDENTIFIED BY 'your_password_here';

And grant the user full access to the database.

GRANT ALL ON yourname_live.* TO 'yourname_live_user'@'localhost' IDENTIFIED BY 'your_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 2: Download WordPress Latest Release

To get WordPress latest release, go to its official download page and get it from there. The following link is from where we can find latest WordPress archive versions.

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/yourprojectname

Now run the commands below to set the correct permissions for WordPress root directory and give Apache2 control

sudo chown -R www-data:www-data /var/www/html/yourprojectname/
sudo chmod -R 755 /var/www/html/yourprojectname/

Step 3: Configure Apache2

Finally, configure Apahce2 site configuration file for WordPress. This file will control how users access WordPress content. Run the following commands to create a new configuration file called yourprojectname.conf

sudo nano /etc/apache2/sites-available/yourprojectname

Copy and paste the following content into ‘yourprojectname.conf’ file and save it. Replace the highlighted line with your own domain name and directory root location.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/yourprojectname
    ServerName example.com
    ServerAlias www.example.com

    <Directory /var/www/html/yourprojectname/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html/yourprojectname/>
        RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*) index.php [PT,L]
    </Directory>
</VirtualHost> 

Save the file and exit.

Step 4: Enable the WordPress and Rewrite Module

After configuring the Virtual Host above, enable it by running the following commands

sudo a2ensite yourprojectname
sudo a2enmod rewrite
sudo systemctl restart apache2.service

Now open your browser and browse to the server domain name. You should see WordPress setup wizard to complete. Please follow the wizard carefully.

http://your_domain_name.com

Follow the on-screen instructions. i.e. select the installation language and click Continue.

WordPress Setup Step 1

You will need to know the following

Before getting started, we need some information on the database. You will need to know the following items before proceeding.

  1. database_name
  2. database_username
  3. database_password
  4. database_host
  5. Table prefix (if you want to run more than one WordPress in a single database)

WordPress will going to use this information to create a wp-config.php file.

WordPress Setup Step 2

Next, you should enter your database connection details and if you’re not sure about these, contact your host.

WordPress Setup Step 3

After that, click Run the installation to complete the WordPress setup.

WordPress Setup Step 4

Next, fill in the WordPress site information and then click Install WordPress

WordPress Setup Step 5

You’re done. WordPress is installed now and ready to use.

Related Post

How to Set Up Nginx Server Block on Ubuntu

Here is how you can set up Nginx Server Block on Ubuntu. In particular on Vultr‘s instance i.e. Ubuntu 16.04 LTS / 18.04 LTS / 22.04 LTS.

How to Install MariaDB on Ubuntu

Here is how you can install MariaDB on Ubuntu. In particular on Vultr’s instance i.e. Ubuntu 16.04 LTS / 18.04 LTS / 20.04 LTS / 22.04 LTS.

Leave a Reply