I have seen some online guides about this but really was after one specific to Ubuntu 12.04. So here goes:
Step 1 – Installing Nginx
First we need to add the Nginx source
sudo add-apt-repository ppa:nginx/stable
Next, as we always do after adding a source, we need to update
sudo apt-get update
And now we install it
sudo apt-get install nginx
Next, we must start the Nginx service.
sudo /etc/init.d/nginx start
To check if it is successful, try going to http://localhost/ in your browser. If you see a Welcome to Nginx page, it has been successful.
Step 2 – Installing PHP5:
Install PHP and any required extensions
sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql
Edit the default Nginx site config (if you are not familiar with vim, try entering ‘nano’ instead)
sudo vim /etc/nginx/sites-available/default
The changes you will need to make are as follows:
1)
index index.html index.htm;
to
index index.html index.htm index.php;
2)
root /srv/http/nginx;
^this path may be different in your install, it doesn’t matter as we are changing it!
to:
root /var/www;
3) uncomment the following lines
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
Now quit vim (‘:wq’) and restart the nginx service.
sudo /etc/init.d/nginx restart
If the folder /var/www/ doesn’t exist, create it
sudo mkdir /var/www/
Step 3 – Install MySQL
And finally,
sudo apt-get install mysql-server
Step 4 – Check it works!
Create a test file
vim /var/www/test.php
Add this line
<?php phpinfo();?>
Save and quit vim (:wq) and go to http://localhost/test.php in your browser.
If you see a page displaying all your PHP settings, then it works!



Home





























