Advance

Install WordPress with LEMP on Ubuntu 18.04

Install WordPress with LEMP on Ubuntu 18.04

Following the series of tutorials WordPress and Ubuntu, in this article, we are going to Install WordPress with LEMP on Ubuntu 18.04. As many of our readers might want to test it on their own server, today we present how to setup WordPress 5 with LEMP on Ubuntu 18.04. And you know that the LEMP is a popular combination of LinuxNginxMySQL/MariaDB, and PHP.

 

Requirements

  • A dedicated server or a VPS (Virtual Private Server) with Ubuntu 18.04 minimal installation

 

Buy virtual private server

Recommended Article: Comparison of virtualmin, webmin and usermin

Install WordPress with LEMP on Ubuntu 18.04

Let’s walk through this guide, to see the installation of all the required packages, creating your own database, preparing vhost, and completing the WordPress installation via a browser.

 

Installing Nginx Web Server on Ubuntu 18.04

After preparing your web server Nginx, run the following command to install the package.

sudo apt update && sudo apt upgrade  sudo apt install nginx
Use the below command to start the Nginx service and automatically start it upon system boot.
sudo systemctl start nginx.service  sudo systemctl enable nginx.service
You may find related useful articles here:

Creating Vhost for WordPress Website on Nginx

In this step, you will create vhost for your WordPress website. Using your preferred text editor, create the following file.
sudo vim /etc/nginx/sites-available/wordpress.conf  
server {      listen 80;      listen [::]:80;      root /var/www/html/wordpress;      index  index.php index.html index.htm;      server_name example.com www.example.com;         client_max_body_size 100M;        location / {          try_files $uri $uri/ /index.php?$args;              }        location ~ \.php$ {      include snippets/fastcgi-php.conf;      fastcgi_pass             unix:/var/run/php/php7.2-fpm.sock;      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;      }  }
Note: Do not forget to replace the example.com with the domain you wish to use.
You can save and close the file now. Then enable the site with:
sudo ln -s /etc/nginx/sites-available/wordpress.conf  /etc/nginx/sites-enabled/  
Next,  reload Nginx with:
sudo systemctl reload nginx   

Installing MariaDB 10 on Ubuntu 18.04

You need to use  MariaDB for your WordPress database, so install it by typing:

sudo apt install mariadb-server mariadb-client  
You can start it and configure it to start automatically on system boot when the installation is complete.
sudo systemctl start mariadb.service  sudo systemctl enable mariadb.service

then, use the following command to secure your MariaDB installation.

sudo mysql_secure_installation  
And finally, answer the questions to complete the task.

Creating a WordPress Database for Website

It is time to prepare the database. The database user and password will be used by your WordPress application so it can connect to the MySQL server.
sudo mysql -u root -p
Using the below command create a database, then a database user and its password. You will grant the user privileges to that database.
CREATE DATABASE wordpress;  CREATE USER 'wp_user'@'localhost' IDENTIFIED BY ‘secure_password’;  GRANT ALL ON wordpress.* TO 'wp_user'@'localhost' ;  FLUSH PRIVILEGES;  EXIT;

 

Installing PHP 7 on Ubuntu 18.04

Install PHP and the required PHP packages to run WordPress, as WordPress is an application written in PHP.

sudo apt install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl  

Start the php-fpm service and enable it, when the installation is complete.

sudo systemctl start php7.2-fpm  systemctl enable php7.2-fpm

 

Installing WordPress 5 on Ubuntu 18.04

Now, download the latest WordPress package.

cd /tmp && wget http://wordpress.org/latest.tar.gz  

And extract the archive with:

sudo tar -xvzf latest.tar.gz -C /var/www/html  

Till here, you would create your document root that we have set in the vhost which is /var/www/html/wordpress. Next, you need to change the ownership of the files and folders within that directory with:

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

In case you have used unregistered/non-existing domain, you can configure your hosts /etc/hosts file, as you are ready to run the installation of your WordPress.

192.168.1.100 example.com  

Consider that your server’s IP address is 192.168.1.100 and the domain you are using is example.com as well your computer resolves example.com on the given IP address.

Load your domain into a browser to see the WordPress installation page:

 

Choose WordPress Install Language

Then, you can see the database credentials that we have set up earlier:

 

wordpress Database Settings

As you see below, you need to submit the form and on the next screen configure your website title, admin user, and email:

 

wordpress setup site info

 

Good job! You finished the installation here and from now on you can start managing your WordPress website. we suggest you start by installing some fresh new themes or extending the site functionality via plugins.

 

Dear user, we wish this tutorial install WordPress with Nginx, MariaDB, and 10 PHP 7 on Ubuntu 18.04 would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.

 

You may also be interested in :

Install WordPress with LEMP on Ubuntu 18.04

How to install LEMP stack on Ubuntu 20.04

Install LAMP stack on CentOS 8

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+18054214518

7 days a week, 24 hours a day