Install WordPress with LAMP Stack on Ubuntu 20.04

WordPress is the most popular open-source content management system for creating blogs today. You can use WordPress to create eye-catching dynamic websites and power all types of mobile and web apps.

This tutorial describes how to download and install WordPress with the LAMP stack on Ubuntu 20.04. The LAMP stack comprises Linux, Apache HTTP server, MySQL/MariaDB, and PHP.

Prerequisites

  • The LAMP stack installed on Ubuntu 20.04
  • A user with Sudo privileges

Download WordPress

As of this writing, WordPress 5.6.2 is the latest version. Run the command below to download the latest WordPress archive.

$ sudo wget https://wordpress.org/latest.tar.gz

Once downloaded, run the next command to extract the wordpress folder and move it to your website root directory. Remember to replace /var/www/cloudindevs with your own website root directory.

$ sudo tar -zxvf ./latest.tar.gz -C /var/www/cloudindevs

Configure MariaDB for WordPress

After extracting the wordpress folder, the next step is to configure MariaDB for use by WordPress. To do this, you need to login to MariaDB as follows.

$ sudo mysql -u root -p

Next, create a database as well as a user for WordPress by running the queries below.

MariaDB [(none)]> CREATE DATABASE wordpress;
Create wordpress database
Create wordpress database
MariaDB [(none)]> CREATE USER wpuser@localhost IDENTIFIED BY 'wpPassword';
Create user for WordPress
Create user for WordPress

Further, grant the wordpress user all privileges on the wordpress database as follows.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost;
Grant privileges on wordpress database to WordPress user
Grant privileges on wordpress database to WordPress user

Now, update the grant tables to save your changes with:

MariaDB [(none)]> FLUSH PRIVILEGES;

Quit MariaDB.

MariaDB [(none)]> QUIT

Install WordPress

After configuring MariaDB, it is now time to install WordPress. Firstly, change directory to the extracted wordpress folder in your website root.

Note: You may install WP CLI tool to install and manage WordPress from command line.

For example:

$ sudo cd /var/www/cloudindevs/wordpress

Secondly, copy the sample configuration file as follows.

$ sudo cp wp-config-sample.php wp-config.php

Thirdly, open the wp-config.php file for editing with the next command.

$ sudo nano wp-config.php

Next, scroll down until you get to MySQL settings. In this section, provide the database name as well as the database username and password which you created earlier while configuring MariaDB for WordPress.

Here is an example.

Configure MySQL settings for WordPress
Configure MySQL settings for WordPress

Save changes and close the wp-config.php file.

Now, open a web browser and go to ServerIP/wordpress. For instance, 192.168.168.192/wordpress.

The WordPress web installer will launch. You would then be asked to provide your site title, username, password and email. Once done, click Install WordPress.

Launch WordPress installer
Launch WordPress installation

After that, you should  see a “Success!” message.

WordPress installed successfully
WordPress installed successfully

Finally, click Login and then enter your sign in details to begin using WordPress.

Conclusion

In this tutorial, we described how to download and install WordPress with the LAMP stack on Ubuntu 20.04. One of the strongest points of WordPress is its ease of use. Do share your thoughts with us.

Leave a Comment