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

in Course, Database, mysql, OS, PHP, Ubuntu / No Comments

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

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

Installation of Nginx:

Commands:

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

Installation of MySql:

Commands:

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:

Command:

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

<?php
    echo phpinfo();
?>

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

PHP default port : 9000

MySql default port : 3306

With more than 8 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : php.anil@gmail.com

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>