From 4def375a381fe12b85457ef106f3247b8a7c6c2a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 27 Dec 2012 18:13:01 +0530 Subject: [PATCH] Nginx WordPress Multisite --- conf/nginx/multisite/subdirectory/simple.conf | 60 +++++++++++++++++++ setup/engine | 8 +-- 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 conf/nginx/multisite/subdirectory/simple.conf diff --git a/conf/nginx/multisite/subdirectory/simple.conf b/conf/nginx/multisite/subdirectory/simple.conf new file mode 100644 index 00000000..b0eda8f6 --- /dev/null +++ b/conf/nginx/multisite/subdirectory/simple.conf @@ -0,0 +1,60 @@ +map $uri $blogname{ + ~^(?/[^/]+/)files/(.*) $blogpath; +} + +map $blogname $blogid{ + default ""; + + #Add list of blogs with their ids. SEE "FILE-HANDLING" SECTION. + #/site1/ 2; + #/site2/ 3; +} + +server { + server_name example.com; + + access_log /var/log/nginx/example.com.access.log; + error_log /var/log/nginx/example.com.error.log; + + root /var/www/example.com/htdocs; + index index.php; + + location ~ ^(/[^/]+/)?files/(.+) { + try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2; + access_log off; log_not_found off; expires max; + } + + #avoid php readfile() + location ^~ /blogs.dir { + internal; + alias /var/www/example.com/htdocs/wp-content/blogs.dir; + access_log off; log_not_found off; expires max; + } + + if (!-e $request_filename) { + # wp-admin to wp-admin/ + rewrite /wp-admin$ $scheme://$host$uri/ permanent; + #other wp-* files/folders + rewrite ^(/[^/]+)?(/wp-.*) $2 last; + #other php files + rewrite ^(/[^/]+)?(/.*\.php) $2 last; + } + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri /index.php; + include fastcgi_params; + fastcgi_pass unix:/var/run/php5-fpm.sock; + } + + location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { + access_log off; log_not_found off; expires max; + } + + location = /favicon.php { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + location ~ /\. { deny all; access_log off; log_not_found off; } +} diff --git a/setup/engine b/setup/engine index fd6caedf..777002c3 100755 --- a/setup/engine +++ b/setup/engine @@ -15,8 +15,8 @@ EngineHelp() echo echo " `basename $0` [site] [read] [all|active|sitename]" echo " `basename $0` [site] [create] [sitename] [--with-wordpress]" - echo " `basename $0` [site] [update] [sitename] [single] [w3total|wpsuper|fastcgi]" - echo " `basename $0` [site] [update] [sitename] [multi] []" + echo " `basename $0` [site] [update] [sitename] [singlesite] [w3total|wpsuper|fastcgi]" + echo " `basename $0` [site] [update] [sitename] [multisite] [subdirectory|subdomain] [w3total|wpsuper|fastcgi]" echo " `basename $0` [site] [delete] [sitename] [--database|--webroot|--all]" echo @@ -487,7 +487,7 @@ then # Remove http:// & www. DOMAIN=$(echo $3 | sed "s'http://''" | sed "s'www.''") - if [ "$4" = "single" ] + if [ "$4" = "singlesite" ] then if [ "$5" = "w3total" ] @@ -546,7 +546,7 @@ then fi - elif [ "$4" = "multi" ] + elif [ "$4" = "multisite" ] then echo "Under Developments !!"