Install WordPress in Ubuntu 20.04 LTS

WordPress is written in PHP. It is basically a free and open-source CMS. CMS is an acronym for content management system. The CMS was developed by Matt Mullenweg and Mike Little. As of now, it is managed by WordPress Foundation. Furthermore, the package was first released on May 27, 2003. In this article, we would discuss how to install WordPress in Ubuntu 20.04 LTS.

WordPress, initially was considered a tool for publishing blogs. But, now it is used to deploy variety of web content. At the time of writing the latest stable WordPress release is 5.4.1 (code name – Adderley).

First, we would install necessary dependencies to install WordPress. Thereafter, we would download the package from official website of WordPress (a tar.gz file).

So, this is what all we have to do –

  1. Install lamp-server,
  2. Create database user and grant necessary privileges,
  3. Install necessary PHP packages,
  4. Edit configuration files, and
  5. Install and setup WordPress.

Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.

Install LAMP Server through tasksel

If in case tasksel package is not installed, then issue the following in terminal –

sudo apt update
sudo apt install tasksel

Next, we would install LAMP Sever through tasksel

sudo tasksel install lamp-server

One benefit of using tasksel is that, we can install multiple packages which are related to each other for a particular task. Therefore, here we have installed all the necessary packages required to setup lamp-server.

Create database user and grant necessary privileges

Setup MySQL for WordPress –

sudo mysql_secure_installation

It will ask us to Validate Password – Press y and thereafter, set password validation policy. We went ahead with STRONG. It will ask us for a password. We chose option YES for all the other prompts. You may choose as per your requirements.

To create a database for WordPress –

sudo mysql -u root -p

Enter the password used earlier. Following commands creates a database – wp_database, user – wp_user, and password – Pqwertyd6*. We have also granted all privileges to the user on WordPress database.

CREATE DATABASE wp_database;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'Pqwertyd6*';
GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost';

Install necessary PHP packages

Install necessary PHP packages. Hence, issue the following in terminal –

sudo apt install php-curl php-mbstring php-xml

Finally, restart apache2.service

sudo systemctl restart apache2.service

Edit configuration files

Since we intend to use the most basic configuration as of now. Therefore, edit the config file – 000-default.conf for hosting just one website on our server.

sudo nano /etc/apache2/sites-available/000-default.conf

and append the file with following entries –

<Directory /var/www/html/>
      AllowOverride All

Next, enable rewrite module. This has numerous advantages like – it allows us to use Permalink feature in WordPress etc.

sudo a2enmod rewrite

Issue the following to identify whether we’ve got an issue –

sudo apache2ctl configtest

It would return with Syntax OK.

Then, restart apache2.service

sudo systemctl restart apache2.service

Install WordPress in Ubuntu 20.04 LTS

On Homepage of official website of WordPress, click Get WordPress button. It will take you to the Downloads page. Therein, download the package file – latest.tar.gz (tar.gz file).

Extract the package using tar command-line utility –

tar -xvf latest.tar.gz

It would create wordpress/ in current directory.

Now, copy wp-config-sample.php as wp-config.php

cp wordpress/wp-config-sample.php wordpress/wp-config.php

Thereafter, copy the entire wordpress/ directory to /var/www/html/

sudo cp -a wordpress/. /var/www/html/

Also, change the ownership of /var/www/html/ to www-data using chown command-line utility.

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

Finally, edit the wp-config.php file –

sudo nano /var/www/html/wp-config.php

and, edit the following entries with data mentioned in section – Create database user and grant necessary privileges

define( 'DB_NAME', 'wp_database' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'Pqwertyd6*' );

Make sure, you also remove index.html file from /var/www/html if it exists. We again reiterate, remove – index.html and not – index.php.

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

Now, open a web-browser and type the following in address bar –


It may ask you for database details – database name, user and password to establish connection with database. If connection gets established, it will start with installation process. In next page, provide details like site title, username and password to login in WordPress.

In conclusion, we have discussed how to install WordPress in Ubuntu 20.04 LTS using package file available on official website of WordPress.

Similar Posts