In this article we will guide you through the steps of installing the latest version of WordPress on an Ubuntu 18.04 VPS, including the installation of Nginx web server, PHP and MySQL database server.
WordPress is a free and open-source CMS based on the PHP and MySQL programming languages. Used by millions of people, it is the world’s most popular content management systems (or CMS for short). With features such as in-depth theming, thousands of plug-ins, and a huge community, WordPress is probably the most user-friendly CMS you can choose. The installation is pretty easy, too – all you need is to closely follow the steps in this tutorial. Let’s get started.
Table of Contents
Prerequisites:
- PHP version 7.2 or newer
- MySQL version 5.6 or greater OR MariaDB version 10.0 or greater.
- Nginx web server
- an Ubuntu 18.04 VPS
- A system user with root privileges, or access to the root account
Step 1: Log in and Update the Server
Login to your Ubuntu 18.04 server via SSH as the root user:
where ‘IP_Address‘ and ‘Port_number‘ are the actual IP address of your server and the SSH port.
Then run the following commands to make sure that all packages are updated to their latest releases.
Step 2: Install Nginx web server
WordPress needs a web server with PHP support to run and render the web pages dynamically. For this, we will install and use the Nginx web server. It is available in the official Ubuntu 18.04 repositories and it can be easily installed using the following command:
After the installation is completed, start Nginx and enable it to start automatically after a reboot:
You can check if the web server is running with this command:
The output should look something like this:
You can also verify if Nginx is running by accessing http://Server_IP_Address
in your preferred web browser.
Step 3: Install and Configure PHP
WordPress is built on PHP, so we have to install PHP as well as several PHP extensions required by WordPress in order for it to function properly:
Now, open the PHP configuration file, find and uncomment the ‘cgi.fix_pathinfo’ line. Open the file with your preferred text editor – we’ll be using Nano:
Then uncomment this line:
Save the configuration file and exit the editor. Then restart the PHP-FPM service for the changes to take effect:
Step 4: Install MySQL Server and Create a Database
WordPress needs an empty MySQL database to store its data such as posts, post types, user profiles, etc. So the next step will be to install the MySQL server and create a user and database for the WordPress installation.
MySQL server can be installed using the following command:
During the installation of the database server, you will be prompted to set a password for the MySQL root user.
After the installation completes, you can check the version of the installed MySQL database server:
Additionally, you can run the mysql_secure_installation
post-installation script to strengthen the security of the database server. We recommend answering with the following answers:
Next, log in to the MySQL server as user root and create a new MySQL user and database
Don’t forget to replace ‘PASSWORD’ with an actual, strong password.
Step 5: Download and Install WordPress
The latest release of WordPress can be downloaded from their official website. At the moment of writing this article it is version 5.2.2. It can be easily downloaded on your Ubuntu 18.04 server using the following command
Once the downloading of the WordPress archive is completed, unpack it to the document root directory of your server
This will create a new ‘wordpress’ directory which will contain all files of the WordPress installation.
Step 6: Configure Nginx
Next, in order to be able to access the WordPress site with your domain name, we will have to create an Nginx virtual block for the domain name:
NOTE: Don’t forget to replace yourdomain.com with your unique registered domain name.
Enable the Nginx virtual block:
You can test if everything is properly configured using the following command:
Once you confirm that everything is OK, restart Nginx for the changes to take effect:
Step 7: Complete the WordPress installation
Once all steps above are done, the installation from the command line is completed. You can open your favorite web browser and point it to http://yourdomain.com
. You should get the following screen:
Select your language and follow the installation wizard to complete the WordPress installation and create your administrative account. Congratulations, you now have WordPressed installed on Ubuntu 18.04 with a LEMP stack.
Of course, if you are one of our WordPress Hosting customers, you don’t have to Install WordPress with LEMP Stack on Ubuntu 18.04, simply ask our admins, sit back and relax. Our admins will Install Install WordPress with LEMP Stack on your Ubuntu 18.04 VPS for you immediately.
PS. If you liked this post on how to install WordPress with LEMP Stack on Ubuntu 18.04, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.
An updated version is available here: How to Install WordPress with LEMP on Ubuntu 20.04.