Home > PHP > Course > How to install Linux, Nginx (Engine X), MySql, PHP (LEMP) on Ubuntu

How to install Linux, Nginx (Engine X), MySql, PHP (LEMP) on Ubuntu

In the earlier post, we learned about how to install PHP installation procedure in Windows, Mac and Linux systems with apache server. In this post, I am going to explain how to install Nginx (Engine X),MySql, PHP (LEMP) server on Ubuntu. Nginx server will suitable for high availability and capable of thousands of requests simultaneously and present days usage of this server is increased as per server statistics. (http://trends.builtwith.com/Web-Server/nginx).

How to install Linux, Nginx, MySql, PHP (LEMP) on Ubuntu by Anil Kumar Panigrahi

Installation of Nginx:


sudo apt-get update
sudo apt-get install nginx
sudo service nginx start

Installation of MySql:


sudo apt-get install mysql-server mysql php5-mysql

MySql system tables installation:

sudo mysql_install_db

MySql installation secure

sudo /usr/bin/mysql_secure_installation

In the next steps sytem prompt for ‘root’ password then provide the root password.

Installation of PHP:


sudo apt-get install php5-fpm

Configuration for PHP

Open a file using below command

sudo gedit /etc/php5/fpm/php.ini

Search for cgi.fix_pathinfo=1 replace it with cgi.fix_pathinfo=0

Default port 9000, to change open the file /etc/php5/fpm/pool.d/www.conf
Once change the port then restart PHP

sudo service php5-fpm restart

Change the default virtual host file then open the file /etc/nginx/sites-available/default

# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ .php$ {
  try_files $uri =404;
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;

From this step we have done the installation.
To effect the above steps then restart the Nginx

sudo service nginx restart

Write the simple PHP file

    echo phpinfo();

Run the PHP file it will display the web server details.

PHP default port : 9000

MySql default port : 3306

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.