Here is how to install nginx on your Raspberry Pi. I have decided to use it instead of apache, because of its great reviews and speed. First off, you need to update the dependencies by typing in apt-get update. Wait a bit for it to finish.

Next, start installing the required packages. Type in apt-get install nginx php5-fpm php5-cgi php5-cli php5-common php5-mysql . This will install nginx along with needed php5 packages. This will take some time, so relax and wait for it to finish. Start the service up by typing service nginx start. Get your IP address by typing in ifconfig. When you have the IP, paste it into the browser. You should get a nice html page, that tells you that nginx is running. So far so good, right?

Now you have to modify the configuration a bit. Type in cd /etc/nginx/sites-available, there is a single file default, which you need to modify with nano. First off, find the line below root /usr/share/nginx/www; . You will need to add support for php files, so type in index.php next to index.html. Leave the remaining line untouched.

Search for a line that starts with pass the PHP scripts to and move down two lines to location ~ \.php$ { . You will be needing this part, so uncomment it by removing the # symbol. Do the same for next line (starts with fastcgi_split_path_info) and the ones below that start with fastcgi_pass unix, fastcgi_index and include fastgi_params. Make sure you do not forget to uncomment the closing curly brace! You need to uncomment the part that denies access to .htaccess files. These lines start with location ~ /\, deny all; and the closing curly brace. For reference, take a look at the sample picture.

install nginx

Save the file by ctr+x and confirm rewriting the file. Restart the service so that the new changes start working. Issue the command service nginx restart. Lets test if .php files are now working. The contents that are displayed on the web are located in /usr/share/nginx/www. Get there and create a sample file with nano test.php.
Type in <?php phpinfo(); ?> and save by ctr+x. Open your browser, put in your ip and new file for example Recheck if a html page appears with only the IP. That is all for now, you have successfully installed nginx!