Nginx + subdomain multi site + w3 total cache + wordpress3.5


Could you provide the necessary rules for w3 total cache under wordpress 3.5? Wordpress completely changed the "Uploaded file path" structure, and therefore half of the rules from your tutorial are now obsolete when performing a fresh install.



All my tutorials here works with WordPress 3.5 without any issue

There are some changes for fresh WordPress 3.5 multisite only. Change is to comment-out 2-3 lines of config but only if your are installing a fresh WordPress 3.5.

User who are upgrading to 3.5 from old versions will need those lines! For this reason, I haven't edited any of my tutorial. Also leaving 2-3 lines extra in nginx config, which will never be used won't degrade performance.

Still for your records following lines from most nginx configs are not required for fresh WordPress-nginx setup:

    location ~ ^(/[^/]+/)?files/(.+) {  
        try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;  
    location ^~ /blogs.dir {  
            alias /var/www/ ;  

Please let me know if you have any questions.

Yeah, after having gone through everything closer, I realized that nothing actually needed to be added/changed. Just removing the the sections that refer to 'files' and 'blogs.dir' (I'm on a completely fresh install.

I ended up changing my config though and went with the fastcgi_cache method instead (in which the same above applies to this one as well) because I was running in to some strange behavior with w3tc.

At any rate, thanks for confirming the changes needed, and thanks for the tutorials, they helped a lot when getting things set up.

Another thing to note though is that I don't think the 'map $http_host $blogid' section is needed anymore either as that seems to have been directly related to the aforementioned 'files' and 'blogs.dir' sections. Can you confirm this?

Thanks again, and have a great day.

map $http_host $blogid

Yes. That entire section can be removed now as it won't be required any more. :-)

@RahulBansal Correct me if I am wrong, but as I see it, this section is REQUIRED:

map $http_host $blogid { ... }  

...if your sub-domain multisite network serves different sites from different domains or sub-domains of different domains. Get the idea of what I am saying?

Small correction: The section is required if your sub-domain multisite network serves different sites from sub-domains of different domains too. I am pretty sure of this. Do let me know if I am wrong!

Okay, nevermind what I said earlier. Just realized I'm wrong!

If you are installing a fresh WordPress, then you don't need map { } block.

From WordPress 3.5, they have stopeed using blogs.dir for fresh setup.

For old WordPress-sites upgraded to 3.5 or newer, map { } block is optional. It is used to improve performance for static file-serving on sub-domain as well sub-dir WordPress multisite.


Should the below line added into nginx in wp 3.5 fresh install? Without the map { } , how does the nginx get the value of $blogid?

location ~ ^(/[^/]+/)?files/(.+) { > try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ; > }


All rules related to blogs.dir & map{ } are not needed on WordPress 3.5 fresh setup.

I will update all multisite-related articles in the series soon. As there are too many articles that need update, its taking time from my end.

But even if you leave this extra lines, nothing will be affected. A reason, I did not rush for quick update!

@rahul.bansal If you are installing a fresh WordPress, then you don’t need map { } block.

If the conf files don't include the map{ } block, the code will stop without the volume of $blogid. How do I deal with it?

location ~ ^(/[^/]+/)?files/(.+) {  
 try_files /wp-content/blogs.dir/**$blogid**/files/$2 /wp-includes/ms-files.php?file=$2  }  

You can remove that line as well.

That line will never be used by a fresh WordPress setup since version 3.5.