How to install LEMP on Ubuntu 18.04?

Windows Articles

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...

How to get Google Opinion Rewards in any Country

Greetings! Google Opinion Rewards is a cool app, which will allow you to earn credit, to spend it on the Google Play...

How to change the hostname on Ubuntu?

This simple tutorial will teach you how to change the hostname on Ubuntu. The steps we will tell you here will work...
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 install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...

How to get Google Opinion Rewards in any Country

Greetings! Google Opinion Rewards is a cool app, which will allow you to earn credit, to spend it on the Google Play...

How to change the hostname on Ubuntu?

This simple tutorial will teach you how to change the hostname on Ubuntu. The steps we will tell you here will work...
x