Created
August 20, 2019 13:58
-
-
Save pbredenberg/3c379f8944d48202c5186587aea8d994 to your computer and use it in GitHub Desktop.
WordPress multisite nginx LEMP
This file contains hidden or 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; | |
listen [::]:80; | |
server_name servername.localdomain; | |
index index.php index.html; | |
root /path/to/root; | |
location ~ /.well-known { | |
allow all; | |
} | |
# Optional: disable xmlrpc for WordPress | |
location = /xmlrpc.php { | |
deny all; | |
access_log off; | |
log_not_found off; | |
return 444; | |
} | |
if (!-e $request_filename) { | |
rewrite /wp-admin$ $scheme://$host$uri/ permanent; | |
rewrite ^(/[^/]+)?(/wp-.*) $2 last; | |
rewrite ^(/[^/]+)?(/.*\.php) $2 last; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?q=$uri&$args; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~* /(?:uploads|files)/.*.php$ { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment