How to install WordPress on Ubuntu 20.04?
Overview
WordPress is an open-source content management system (CMS) based on PHP and MySQL used to create and manage websites, blogs, and other web-based content. Used by over 60+ million websites, it is highly customizable, with thousands of themes and plugins available to extend its functionality. Additionally, WordPress has a large community of users and developers that contribute to the platform and create a wide variety of plugins that can be used to extend its functionality.
This tutorial will show you how to set up WordPress using the LAMP stack on Ubuntu 20.04, by installing and configuring the Apache web server and MySQL database server.
Prerequisites
There are certain prerequisites that need to be met before you begin.
Ubuntu 20.04
SSH connected text editor
Internet connection
LAMP Stack Installation
LAMP is a software stack that consists of Linux as OS, Apache as web server, MySQL as DBMS and PHP as programming language that together allow developers to create and host websites and web applications. The following instructions will give you a walkthrough of the installation process.
To proceed, you can either log in as the root user by running the following command or continue without root access. Here, we are accessing the root user by executing the following command:
Use the following command to update and upgrade the system:
The update command only retrieves information on the most recent versions of packages available for your system, it does not download or install any packages. To download and upgrade packages to the new version, you must use the apt upgrade command.
Step 1: Installing Apache Web Server
Let's begin by installing Apache. To do so, we will use the below command:
To verify that Apache web server is properly installed, use the command below to check its status:
To ensure the successful installation of Apache, you can also open your browser and navigate to your server's IP address.
Step 2: Installing MySQL
MariaDB is a free, open-source RDBMS that is a fork of MySQL, that can be used in conjunction with WordPress. It is designed to be a drop-in replacement for MySQL, offering many of the same features and performance improvements.
To use MariaDB with WordPress, you first need to install and set up MariaDB on your server.
It is essential to run a security script after installing the database server in order to guarantee the security of your database system. With the following command, this script will remove any vulnerable default settings and safeguard your database system:
In the upcoming steps, you will be asked several questions regarding the configuration setting of MySQL database. You need to answer these by entering Y (yes) or N(no):
Before you can access the database, you will be prompted to modify the root password in the first step. If you are certain that your password is secure, you can choose to update it by typing Y or skip it by typing n.
Just for safety purposes, you’ll be asked to remove any anonymous user.
The next step is to disable remote root login so that hackers cannot access your database. However, if you are setting up a virtual server, you might wish to enable remote login for testing purposes.
Moving ahead, you may remove the test database as well.
For listing all the effective changes made, you need to reload the database.
Step 3: Installing PHP
We will install PHP using the following command:
Now, confirm the accurate PHP installation by creating a file named info.php at the core location of the LAMP stack i.e., /var/www/html/
Now, add these lines in the recently created info.php file
Save and exit the terminal by pressing the esc key and then typing the below command:
Open your browser and enter your server’s link, just like the command below:
Step 4: Creating WordPress Database
Now that we have installed and configured MySQL, let's create a database to hold our WordPress data. For that, you need to log in as a root user to our MariaDB database.
Create a database for the WordPress installation with the following command:
Now, create a database user and set a password for the same.
In the next step, you need to give privileges and permissions to the user to access the databse:
The database has been successfully created; you can exit the database now:
Step 5: Installing and Configuring WordPress
Enter the following command to install WordPress from the official repository. Here, we are downloading the tar file, containing all the WordPress dependencies compressed together. You can also create a new directory and download wordpress within it.
After successful installation, you need to uncompress the downloaded .tar file, this will produce a folder named WordPress, using the command below:
Now, in order to sync your downloaded WordPress with the above installed LAMP stack, you need to copy the uncompressed .tar folder to /www/html/var folder, using the below command:
We will ensure that the webserver user (www-data) and its user group have ownership of the website directory by entering the following command:
Change the WordPress folder’s access permissions using the following command:
Chmod 775 alters the permissions so that only authorized users have access to read, write, and execute. (G)group has the ability to read, write, and execute. Others have the ability to read, write, and execute. Additionally, you may explore more and set several other permissions using the chmod command.
Additionally, you may make and change the permissions for the upload directory as well. This should be created into the subfolder of WordPress folder, using the following command:
Just before visiting your web- browser, make sure to restart all the installed services with the following commands:
Finally, now you can access your WordPress by accessing the IP address in your internet browser.
Step 6: Setting up WordPress
After visiting your server’s IP address, you will be prompted to a WordPress wizard, asking you to set it up with on-screen instructions. Select your preferred language.
Fill up the form using the credentials that were used to create the WordPress database in the MariaDB database. Without providing the database host or table prefix, click the Submit button.
If all the details that you provided are up to the mark, you’ll be landed upon the installation page. Click on Run the Installation.
Complete the necessary extra information, including the site title, username, and password, and save it in a secure location in case you forget. Make sure to choose a secure password.
You have successfully installed WordPress.
Enter the already set credentials and click Log In.
Here, you have the options of Remember Me, Forget Password and a sample blog site of your page.
Here opens your dashboard, where you can be you and start your journey of innovative blogs and websites.
Congratulations on completing the installation, your WordPress dashboard is now live.
Last updated