Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 22.04 LTS


LEMP is the stack of LinuxNginxMySQL and PHP, We can deploy PHP based project on LEMP server and also LEMP is so popular for WordPress CMS to build a website for their client, We can install LEMP server on AWSAzure/GCP and other cloud platform and scale also.

Know about LEMP Stack

Linux – Linux is a Unix-like operating system that uses a command line interface. It is one of the most popular operating systems on the internet and is used by a wide variety of organizations, from small home offices to large corporations. Linux is free and open source software, meaning that it is distributed under a license that allows anyone to use, copy, modify, and distribute it.

MySQL – MySQL is a relational database management system that is freely available. Its name is a combination of “My,” which is the name of the daughter of co-founder Michael Widenius, and “SQL,” which is an abbreviation for Structured Query Language.

PHP – PHP is a server side scripting language designed specifically for web development, created it in 1993 and released it in 1995. The PHP Group now produces the PHP reference implementation.

Nginx – Nginx is a reverse proxy, load balancer, mail proxy, and HTTP cache in addition to being a web server. Igor Sysoev developed the software, which was made available to the public in 2004. Nginx is open-source software that is free and distributed under the 2-clause BSD license.

In this post, We will know how to install LEMP server on ubuntu 22.04 LTS.


You will need an Ubuntu 22.04 server, a non-root sudo-enabled user account, and a basic firewall to finish this tutorial.

Step 1: Update the System

We need to update the cache of the package manager by using the given command.

sudo apt-get update 

Step 2: Install Nginx Web server

After updating the ubuntu current repo, We are good to install nginx package using following command.

sudo apt-get install nginx -y

Step 3: Verify the Nginx Service

After installation of nginx package, We need to check nginx service is running or not, Kindly use the following command for the same.

sudo systemctl status nginx.service

You have have up and runing nginx service after execution the above command.

Note: To use the nginx web server from outside the private network, you must either enable or disable port 80 in your OS lever and network lever firewalls.

Step 4: Installing PHP

In this step, We need to install PHP and required PHP module, Use the following command for the same.

sudo apt-get install php php-curl php-json php-cgi php-gd php-mbstring php-xml php-xmlrpc libapache2-mod-php php-mysql -y

Step 5: Installing MySQL Server

In order to install MySQL server on ubuntu, You need to execute the given command for the same.

sudo apt-get install mysql-server -y

To check MySQL service.

sudo systemctl start mysql.service

Use the following command as the root user to secure the MySQL server after the aforementioned packages have been successfully installed.

sudo mysql_secure_installation

You will asked for the some configuration and security setting, You should choose the option as per your need.

Step 6: Testing PHP with Nginx Web Server

We need to create a php file and add given code to get PHP information using apache web server endpoints.

Create a phpinfo.php file in /var/www/html location.

sudo echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php

After that, you need to enter the given URL into the web browser, You need to open the browser witg given web address to get PHP information test page.

http://localhost/phpinfo.php or http://IP_Address/phpinfo.php

You should get web page like this.


We have successfully installed the LEMP server on ubuntu 22.04 LTS, If you still have questions, please post them in the comments section below.


Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 22.04 LTS

4 thoughts on “Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 22.04 LTS

  1. Great beat ! I would like to apprentice while you amend your web site, how could i subscribe for a blog site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept

Leave a Reply

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

Scroll to top