Advance

Install WordPress with LEMP on Ubuntu 18.04

Install WordPress with LEMP on Ubuntu 18.04
4
(1)

Following the series of tutorials on 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 with LEMP on Ubuntu 18.04. And you know that the LEMP is a popular combination of LinuxNginxMySQL/MariaDB, and PHP. If you want to purchase an Ubuntu VPS server, you can check out the packages offered on the Eldernode website.

Recommended Article: Comparison of virtualmin, webmin and usermin

In the continuation of this article from the Ubuntu training, we will teach you how to install WordPress with LEMP on Ubuntu 18.04.

Requirements

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

Install WordPress with LEMP on Ubuntu 18.04

Let’s go to see how to install WordPress with LEMP on Ubuntu 18.04. Walk through this guide, to see the installation of all the required packages, create your own database, prepare a virtual host, and complete the WordPress installation via a browser.

Installing Nginx Web Server on Ubuntu 18.04

You need to set up the Nginx web server to install WordPress with LEMP on Ubuntu 18.04. First, update your system packages with the following command:

sudo apt update   sudo apt upgrade

Now install Nginx using the following command:

sudo apt install nginx
Now start the Nginx with the following command:
sudo systemctl start nginx
You can enable it using the following command:
sudo systemctl enable nginx

Installing PHP on Ubuntu 18.05

Now you should install PHP and the required PHP packages to install WordPress with LEMP on Ubuntu 18.04, as WordPress is an application written in PHP:

sudo apt install php php-mysql php-fpm php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client  

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

sudo systemctl start php7.2-fpm

Then enable it by entering the following command:

sudo systemctl enable php7.2-fpm

Installing MariaDB on Ubuntu 18.04

It’s time to install MariaDB. This step is needed for installing WordPress with LEMP on Ubuntu 18.04. To do this, enter the following command:

sudo apt install mariadb-server   
You can start and ensure that MariaDB is running with the following command:
sudo systemctl start mariadb.service

Then enable MariaDB using the following command:

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. To do the questions, enter Y.

Creating a WordPress Database for Website

It is time to prepare the database before installing WordPress with LEMP on Ubuntu 18.04. 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 creates a database, then a database user and its password. You will grant the user privileges to that database.
CREATE DATABASE wordpress;  GRANT ALL ON wordpress.* TO 'wp_user'@'localhost' ;  FLUSH PRIVILEGES;  EXIT;

Creating Virtual host for WordPress Website on Nginx

In this step, you should create a Virtual host for your WordPress website to install WordPress with LEMP on Ubuntu 18.04. To do this first, download the WordPress archive with the following command:
sudo mkdir -p /var/www/html/wordpress.conf  wget http://wordpress.org/latest.tar.gz
Now extract it with the following command:
tar xfvz latest.tar.gz

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

sudo chown -R www-data: /var/www/html/wordpress/  sudo chmod -R 755 /var/www/html/wordpress/
Using your preferred text editor, create the following file.
sudo nano /etc/nginx/sites-available/wordpress.conf  

Add the following content:

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 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  sudo ln -s /etc/nginx/sites-enabled/
Next,  reload Nginx with:
sudo systemctl reload nginx

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

http://Server_IP/  

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 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 process of WordPress with LEMP on Ubuntu 18.04 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.

Recommended Article: Install WordPress with LEMP on Ubuntu 18.04

Conclusion

In this article, we taught you how to install WordPress with LEMP on Ubuntu 18.04. We wish this tutorial install WordPress with Nginx, MariaDB, and PHP on Ubuntu 18.04 would be helpful for you, to ask any questions 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.

 

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

+8595670151

7 days a week, 24 hours a day