How to install WordPress on Ubuntu 20.04

Prerequisites:

To secure MariaDB, run the following command.

mysql_secure_installation

This will prompt for a series of options and you can set it with either Y or n

Output:

root@vps:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

You can answer Y (yes) to all the questions, and then setup will complete.

Creating the new database. Log into MySQL with the following command.

mysql

First, we'll create a new database.

MariaDB [(none)]> CREATE DATABASE wordpress_db;

Next, create a new MySQL user account that we will use to operate on WordPress's new database, with username "wordpress_user".

MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';

Link the user and DB together by granting our user access to the database.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';

Flush the privileges so that MySQL knows about the user permissions we just added.

MariaDB [(none)]> FLUSH PRIVILEGES;

Exit out of the MySQL command prompt by typing.

MariaDB [(none)]> exit

Output:

root@vps:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE wordpress_db;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> exit
Bye

Download and install WordPress

Download Wordpress.

 wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz

Unzip the downloaded WordPress file.

 tar -xzvf /tmp/wordpress.tar.gz -C /var/www

Change the permission of the site directory.

chown -R www-data.www-data /var/www/wordpress

Navigate to your browser.

http://IP_ADDRESS

images

Start a WordPress installation by clicking on the Run the installation button.

images

Provide the requested information.

images

Once the Wordpress is installed login with your new user credentials.

images

images