How to Install LEMP stack (Linux, Nginx, MySQL, PHP) for Ubuntu 16.04

Here we will go through list of steps to install LEMP for Ubunutu 16.04 in a easy way.

After logging into the server using SSH,

Step 1: Have to update the default packages.

Step 2: Install nginx

After the installing nginx you can check start the server and know the status for the same.

You can see the status as active or running. To make sure everything works fine, just go through your site or newly created ip address. You can see the following

Install LEMP nginx in ubuntu 16.04
Once the nginx installed successfully we can go and install the mysql

Step 3: Installing MYSQL

Here we will install both mysql server and client,

During the installation process it will ask for password. Default user name would be root. After the successful installation of mysql server and client, will start the server and check for status for the same.

Step 4: Installing PHP

It will install latest PHP version and required mysql for the same. Start and check the status of PHP.

If you want to install PHPMyAdmin you can do it by following

During the installation you can select apache2 server and enter the password for login. Again here the default user name is root.
Step 5 – Configure Nginx to use the PHP Processor

Once all the required packages installed you can restart nginx. And setup the configuration to handle the server to support PHP running smoothly.

Here you can see the default configuration to handle server details. Let’s update it by following way.

If you want to specify cache control for the images, css and js files, you can set it up as following in the server.

You can test for any syntax error before restarting the nginx

Additionally you may required to install basic php modules to run all php functionalities. So you can install these modules.

Step 6: Installing Composer

How the PHP live without composer packages in this era. Let’s install our composer.

Here you are installed LEMP for Ubuntu 16.04. Now you can proceed with setting up your project and run your site.


  1. By Theresa


  2. Reply

  3. Reply

  4. Reply

Leave a Reply

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