Skip to content

Instantly share code, notes, and snippets.

@raedatoui
Created April 7, 2012 05:43
Show Gist options
  • Save raedatoui/2325600 to your computer and use it in GitHub Desktop.
Save raedatoui/2325600 to your computer and use it in GitHub Desktop.
nginx worpdress config
server {
listen 80;
server_name raedatoui.com www.raedatoui.com;
access_log /srv/www/raedatoui.com/logs/access.log;
error_log /srv/www/raedatoui.com/logs/error.log;
root /srv/www/raedatoui.com/public;
location / {
#index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
#Global restrictions configuration file.
# Designed to be included in any server {} block.</p>
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny access to any files with a .php extension in the uploads directory
location ~* ^/wp-content/uploads/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
# Deny access to any files with a .php extension in the uploads directory for multisite
location ~* /files/(.*).php$ {
deny all;
access_log off;
log_not_found off;
}
# WordPress single blog rules.
# Designed to be included in any server {} block.
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
if ($uri !~ "^/wp-content/uploads/") {
fastcgi_pass 127.0.0.1:9000;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment