NGINX configuration for php7 on Ubuntu

Once again lets do a backup of the config file we are about to configure:

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default-backup

open the file up to configure:

sudo nano /etc/nginx/sites-available/default

make the following changes

server {

	location / {
    	try_files $uri $uri/ =404;
	}

	error_page 404 /404.html;
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
    	root /usr/share/nginx/html;
	}

	location ~ \.php$ {
    	try_files $uri =404;
    	fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    	fastcgi_index index.php;
    	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    	include fastcgi_params;
	}
}

Restart the Nginx service for changes to take effect with:

sudo nginx -t  
sudo service nginx restart  

Add your comment