Nginx, PHP, Mysql on Ubuntu

Nginx (pronounced “Engine-X”) is an open source Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, AIX, HP-UX and Microsoft Windows.
Replacing apache with nginx in LAMP, Linux with nginx, php and mysql is another way to build a general purpose web server.

LNMP on Ubuntu 12.04 Precise.

1. Install mysql:

sudo apt-get install mysql-server mysql-client
while installation, it will prompt to set mysql root password.

2. Install nginx:

sudo apt-get install nginx

Then start nginx via:
sudo /etc/init.d/nginx start

web files host under /usr/share/nginx/www

3. In web browser, input http://localhost to test if nginx works.

4. Install php5

sudo apt-get install php5-fpm

5. Configure nginx.nginx configuration file is /etc/nginx/nginx.conf
Read:
http://wiki.nginx.org/NginxFullExample
http://wiki.codemongers.com/NginxFullExample2

6. Check if php is running.create and edit info.php under /usr/share/nginx/www/

sudo nano /usr/share/nginx/www/info.php

add following code and save it:
<!–?php
phpinfo();
?>
then visit http://localhost/info.php

7. Install following packages to add module and restart php

sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

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

———————————————————-

source: http://ubuntuguide.net/setup-nginx-php-mysql-ubuntu12-04