How To Install WordPress on Ubuntu 20.04

Author: Kenneth ([email protected])

Published: Tuesday March 23, 2021

What is Ubuntu?

Ubuntu is a Linux based operating system. It is designed for smartphones, computers, and network servers. The system has been developed by a UK-based company called Canonical Limited, based on all the principles used to develop Ubuntu software and the principles of open source software development.

What is WordPress?

WordPress is the most popular CMS. It is based on PHP and MySQL. The features of WordPress extended with millions of free plugins and themes.

Lets Get Coding

Install WordPress

Let us install all dependencies and WordPress itself.

apt update
apt install php libapache2-mod-php mysql-server php-mysql
cd /var/www/
tar -xzvf latest.tar
cp wp-config-sample.php wp-config.php

Configure MySQL Database

Now, log into the MySQL root (administrative) mysql command, then the following statements.

mysql -u root -p;
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'wordpress'@'localhost';

Now, let’s configure WordPress to use this database. Use nano to open /var/www/wordpress/wp-config.php.

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');

Configure Apache for WordPress

Modify /etc/apache2/sites-available/000-default.conf by changing the following:

DocumentRoot /var/www/wordpress

Enable URL rewriting with a2enmod rewrite and reload apache2 with service apache2 reload.


Open your IP Address in your browser. You will be asked for title of your new site, username, password and address e-mail. You can choose if you want to make your site indexed by search engines. You can now login under localhost/wp-login.php.

This solution requires you to have root access. So we recommend choosing a host with one. We recommend DigitalOcean.