Skip to content

Instantly share code, notes, and snippets.

@vormwald
Created July 21, 2013 19:31
Show Gist options
  • Save vormwald/6049652 to your computer and use it in GitHub Desktop.
Save vormwald/6049652 to your computer and use it in GitHub Desktop.
My Wordpress nginx setup
# This is a site specific file, everything else is taken care of in /etc/nginx/nginx.conf
server {
listen 80;
server_name www.sitename.com;
return 301 http://sitename.com$request_uri;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
server_name sitename.com;
access_log /var/log/nginx/sitename.access.log;
error_log /var/log/nginx/sitename.error.log;
root /opt/sites/sitename;
client_body_timeout 160;
client_header_timeout 160;
send_timeout 160;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /nginx_status {
stub_status on;
access_log off;
allow all;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
#index index.html index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment