Skip to content

Instantly share code, notes, and snippets.

@pbredenberg
Created August 20, 2019 13:58
Show Gist options
  • Save pbredenberg/3c379f8944d48202c5186587aea8d994 to your computer and use it in GitHub Desktop.
Save pbredenberg/3c379f8944d48202c5186587aea8d994 to your computer and use it in GitHub Desktop.
WordPress multisite nginx LEMP
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