Skip to content

Instantly share code, notes, and snippets.

@codex5
Forked from graham-aa/multisite.conf
Created August 19, 2022 14:21
Show Gist options
  • Save codex5/fe16936b4af16e66a494727b9ac48879 to your computer and use it in GitHub Desktop.
Save codex5/fe16936b4af16e66a494727b9ac48879 to your computer and use it in GitHub Desktop.
WordPress NGINX MultiSite Config
server {
listen 80;
server_name site_url;
root /dir/of/site;
# access_log /srv/www/domain.com/log/access.log;
# error_log /srv/www/domain.com/log/error.log;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
# 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;
}
# this prevents hidden files (beginning with a period) from being served
location ~ /\. { access_log off; log_not_found off; deny all; }
# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;
if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location ~ \.php$ {
# client_max_body_size 25M;
try_files $uri =404;
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /dir/of/site$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment