How to install LEMP on Ubuntu 18.04?

Windows Articles

How to Update to MIUI 12 via Fastboot

Greetings friends. The new version of the Android-based operating system MIUI 12 released this year, is still being deployed with some devices missing. On...

How to use modprobe command?

The modprobe command is a Linux administration system created for management, visualization, inclusion and exclusion. From loadable modules to kernel. Also, the Module is...

Install Virtualmin on CentOS 8

Hello, friends. In this post, you will learn how to install Virtualmin on CentOS 8. In addition to that, we will leave it ready...

Different ways to open File Explorer in Windows 10

Hello! Certainly the archive scan is an essential element when it comes to controlling the contents. It is even so important, that there are...

How to setup WireGuard VPN with ubuntu 20.04

Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. Wireguard® is an amazingly straightforward yet quick and present-day VPN that...
angeloma
angeloma
Senior Writer and partner

It is increasingly common to find LEMP servers on the market. This is because it allows you to have a more prepared web server for more numerous connections. As well as many simultaneous requests. Unlike LAMP, installing LEMP on Ubuntu 18.04 requires a few extra steps to make everything work. Anyway, it’s not a complex process and it is within most people’s reach. So, in this post, you will learn to install LEMP on Ubuntu 18.04.

LEMP refers to a set of software that together provides a web server. The main difference with LAMP is that it replaces Apache with another HTTP server, usually Nginx. We have talked a lot about Nginx, and it is one of the most important applications for the web, where a large number of websites use it. The main features of Nginx are performance and scalability.

Install LEMP on Ubuntu 18.04

Install Ubuntu 18.04

If you have not yet installed Ubuntu 18.04 or do not know how to do it. Here is a tutorial for you to do it without problems.

Install Nginx

Now we can install the second component of LEMP. Nginx is a wonder as a web server. Its performance is enviable and that’s why it has become a formidable option to serve websites. Especially when these websites have a lot of traffic.

Nginx is in the official Ubuntu 18.04 repositories, so open a terminal and run.

:~$ sudo apt install nginx

1.- Install Nginx
1.- Install Nginx

And that’s enough. If you use a firewall like ufw, remember to enable ports 80 and 443.

Then open a web browser and access your server. You can do it by the IP address of the same or through the domain.

image

So, Nginx is properly installed.

Install PHP to work with Nginx

Now it’s PHP’s turn, so let’s install it together with php-fpm to work with Nginx.

:~$ sudo apt install php php-cli php-fpm php-mysql

2.- Install PHP
2.- Install PHP

After that, edit the php.ini file.

:~$ sudo nano /etc/php/7.2/fpm/php.ini

And change the following line:

;cgi.fix_pathinfo=1

To:

cgi.fix_pathinfo=0

3.- Edit the php.ini config file
3.- Edit the php.ini config file

Save and close the file. Next, restart php-fpm.

:~$ sudo systemctl restart php7.2-fpm

Now you have to make some changes to Nginx to make everything work well. So edit the following file:

:~$ sudo nano /etc/nginx/sites-available/default

On the server section. Add index.php. And set the server_name to the server IP or the FQDN.

4.- Configuring PHP and Nginx
4.- Configuring PHP and Nginx

Then, scroll down to the location section and uncomment the include, fastcgi_pass, location, deny all lines. As in the image.

5.- Configuring PHP and Nginx
5.- Configuring PHP and Nginx

Save and close the file. Then, restart Nginx.

:~$ sudo systemctl restart nginx

Next, test PHP. To do it, create a new file .php and open it from the web browser.

:~$ sudo nano /var/www/html/test.php

And add the following.

<?
phpinfo();
?>

6.- Testing PHP
6.- Testing PHP

Finally, open it using the web browser.

Install MariaDB

Now we need to install MariaDB for this, we will use the version that is in the official repositories. So, let’s install it.

:~$ sudo apt install mariadb-server

7.- Install MariaDB
7.- Install MariaDB

Then, configure it using the mysql_secure_installation script.

:~$ sudo mysql_secure_installation

8.- Install MariaDB
8.- Configuring MariaDB

With this script, you will be able to define the root password and other options. So read them and answer what your server needs.

And that’s it.

Conclusion

As you can see, installing LEMP on Ubuntu 18.04 is quite a simple process. With this, you will have a web server quite competent and specialized in websites with high traffic.

Please share this post with your friends.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to Update to MIUI 12 via Fastboot

Greetings friends. The new version of the Android-based operating system MIUI 12 released this year, is still being deployed with some devices missing. On...

How to use modprobe command?

The modprobe command is a Linux administration system created for management, visualization, inclusion and exclusion. From loadable modules to kernel. Also, the Module is...

Install Virtualmin on CentOS 8

Hello, friends. In this post, you will learn how to install Virtualmin on CentOS 8. In addition to that, we will leave it ready...

Different ways to open File Explorer in Windows 10

Hello! Certainly the archive scan is an essential element when it comes to controlling the contents. It is even so important, that there are...

How to setup WireGuard VPN with ubuntu 20.04

Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. Wireguard® is an amazingly straightforward yet quick and present-day VPN that...
x