Skip to content

Instantly share code, notes, and snippets.

@rolandboon
Created January 2, 2013 19:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandboon/4437294 to your computer and use it in GitHub Desktop.
Save rolandboon/4437294 to your computer and use it in GitHub Desktop.
Example config file for a php vhost on nginx, implementing a couple of best practices from http://wiki.nginx.org/Pitfalls.
server {
server_name www.domain.com;
root /home/vhosts/www.domain.com/public;
location / {
index index.php index.html index.htm index.phtml;
try_files $uri $uri/ /index.php; # http://wiki.nginx.org/Pitfalls#Check_IF_File_Exists
}
location ~ \.php$ {
try_files $uri =404; # http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP
fastcgi_pass 127.0.0.1:49232;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # http://wiki.nginx.org/Pitfalls#FastCGI_Path_in_Script_Filename
include /etc/nginx/fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment