Last active
March 1, 2018 19:33
-
-
Save magician11/aa5f34fb12f267fe11672e6e32fba506 to your computer and use it in GitHub Desktop.
Server block example for a WordPress site on Nginx on a DigitalOcean droplet
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 { | |
server_name www.goforself.me goforself.me; | |
listen 80; | |
client_max_body_size 20M; | |
port_in_redirect off; | |
access_log /var/log/nginx/goforself.me.access.log; | |
error_log /var/log/nginx/goforself.me.error.log error; | |
root /var/www/goforself; | |
index index.php; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# Cache static files for as long as possible | |
location ~*.(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|cur)$ { | |
expires max; | |
log_not_found off; | |
access_log off; | |
} | |
# Deny public access to wp-config.php | |
location ~* wp-config.php { | |
deny all; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_pass unix:/run/php/php7.0-fpm.sock; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
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