Skip to content

Instantly share code, notes, and snippets.

@seancallaway
Created February 1, 2016 16:43
Show Gist options
  • Save seancallaway/7e02afd71463d72f5c75 to your computer and use it in GitHub Desktop.
Save seancallaway/7e02afd71463d72f5c75 to your computer and use it in GitHub Desktop.
server {
listen 80;
listen [::]:80;
root <PATH_TO_DOCUMENT_ROOT>/html;
index index.php index.html index.htm;
server_name www.<DOMAIN_NAME> <DOMAIN_NAME>;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# Add trailing slash to wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ [^/]\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment