-
-
Save dz0ny/3806403 to your computer and use it in GitHub Desktop.
Sample of nginx config for php wordpress sites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
root /opt/WordPress/; | |
index index.php index.html index.htm; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# Cache static files for as long as possible | |
location ~* \.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { | |
try_files $uri =404; | |
expires max; | |
access_log off; | |
} | |
# Deny access to hidden files | |
location ~* /\.ht { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Pass PHP scripts on to PHP-FPM | |
location ~* \.php$ { | |
# Zero-day exploit defense. | |
# http://forum.nginx.org/read.php?2,88845,page=3 | |
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi. | |
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked. | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
try_files $uri /index.php; | |
fastcgi_index index.php; | |
fastcgi_pass 127.0.0.1:9000; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param SCRIPT_NAME $fastcgi_script_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment