Installing Nginx with PHP5-FPM on Debian


Install PHP5-FPM as described here.

Install Nginx: apt-get install nginx

Check for the correct path to the socket used by php5-fpm in /etc/php5/fpm/pool.d/www.conf (to be used in the nginx configuration):
listen = /var/run/php5-fpm.sock

Create a virtual host in /etc/nginx/sites-available/:
server {
        listen   80; 
        root /var/www;
        index index.php index.html index.htm;
        server_name YOUR_SERVER_NAME;

        location / {
                try_files $uri $uri/ /index.html /index.php;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

Replace root, server name and the above checked socket to fit your environment. In this case I call the file your_new_vhost.

Activate the new virtual host by placing a symlink in /etc/nginx/sites-enabled/:
ln -s /etc/nginx/sites-available/your_new_vhost /etc/nginx/sites-enabled/your_new_vhost

Restart nginx: /etc/init.d/nginx restart