How to Install LEMP on Ubuntu

Install LEMP on Ubuntu

LEMP is an opensource software known as acronym which is used to serve a dynamic web page and applications.  This term really focus on Nginx framework and lot more faster than the Apache.

Therefore, for installing Lemp on Ubuntu, follow the below steps :

Step 1: Update the system

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove

2: Install Nginx  on your system

sudo apt-get install nginx.service

3: Now, try to start your Nginx

Sudo systemctl enable nginx.service
sudo systemctl start nginx.service

4: Check out it’s status

sudo systemctl status nginx

5:Install MariaDB Database Server

sudo apt-get install mariadb-server mariadb-client

After installing mariadb server, you have to follow below step.

6: Start enable MariaDB Database Server

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

7: Run below command to make secure MariaDB server

sudo mysql_secure_installation

8: Log into mariadb server

sudo mysql -u root -p

After you are successfully logged in,  you we be in mariadb server and you can easily change your root id and password.

9: Install PHP-FPM

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

After installing php, hence you have to run the below command

php -v

You have to know that, its version 7.2, so you have to write 7.2 on configuration settings.

sudo nano /etc/php/7.2/fpm/php.ini

Therefore, You have to edit it and have to insert the  below command:

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 200M
max_execution_time = 360

Now, save it and close the file.

Step 10: Restart nginx

sudo systemctl restart nginx.service

Hence, you have to create phphinfo.php file in nginx root directory and edit it.

sudo nano /var/www/html/phpinfo.php

edit it with below command:

<?php phpinfo( ); ?>

Save the below file and now open the Nginx configuration file.

sudo nano /etc/nginx/sites-available/default

Then uncomment php block:

# pass PHP scripts to FastCGI server
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass;

therefore, save the file and exit it.


Hence, go to the browser and open  URL:


Now, php test page will appear, that means you have successfully installed LEMP in Ubuntu.



0 0 vote
Article Rating

You may also like...

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x