NGINX on Ubuntu

[NGINX](http://nginx.org) is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and the most important, web server. NGINX uses PHP-FPM to process PHP files.

Official NGINX ppa is available for Ubuntu that installs the latest stable version of NGINX available for the specific version Ubuntu on your system is running.

If you are running Ubuntu Server (Ubuntu desktop build already comes with this package).

sudo apt-get install software-properties-commonCode language: JavaScript (javascript)

Adding NGINX ppa to your system

sudo apt-add repository ppa:nginx/stable

Updating your local package manager database.

sudo apt-get updateCode language: JavaScript (javascript)

Installing NGINX

sudo apt-get install nginx-fullCode language: JavaScript (javascript)

Installing PHP-FPM (NGINX will process php files).

sudo apt-get install php5-fpmCode language: JavaScript (javascript)

Add the following lines to your nginx config “/etc/nginx/sites-enabled/default`.`

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;`
}
Code language: Nginx (nginx)

Now we can start PHP5-FPM`.

sudo /etc/init.d/php5-fpm start

Now you can create an index.php file in /usr/share/nginx/html/ to test your web server configuration and add the lines below to it.

<?php 

phpinfo();

?>

Code language: PHP (php)

Now you have NGINX installed on your Ubuntu powered system. If you have any problem feel free to leave a comment below.