BoldGrid / w3-total-cache

GNU General Public License v2.0
152 stars 85 forks source link

Enabling Minify, missing Install instructions for nginx #178

Open dingman opened 4 years ago

dingman commented 4 years ago

After I enable Minify, and enable URL Rewrite, I get a 404 when viewing the generated CSS/JS files.

Upon going to Install, I do not see any Nginx install instructions.

I've spent much time researching, but no resolution yet.

Please advise and see if this can be updated within the plugin for Nginx adminsitrators.

dingman commented 4 years ago

While the instructions do seem to be missing, I did find correct syntax that was successful.

https://gist.github.com/JannieT/171c88171c01c6c8d17932a1027692d7

ghost commented 4 years ago

I was facing the same issue and I've fixed it by changing my Nginx configuration. I think I can help you if you post your Nginx configuration here?

The config file that you sent above is not ideal for W3TC. Because W3TC is generating a configuration called "nginx.conf" in the web document folder and it's changing dynamically and depends on your own settings.

All you need is to include the "nginx.conf" in your Nginx virtual host. include /var/www/vhosts/yoursite.com/nginx.conf;

Also, I recommend you restrict public access to that file:

location = /nginx.conf {
deny all;
}

If you use WP multisite (sub-directory), you also need to add below snippet:

    if (!-e $request_filename) {
        rewrite ^/(blog1|blog2)/(wp-(content|admin|includes).*) /$2;
        rewrite ^/(blog1|blog2)/(.*.php)$ /$2;
    }

NOTE that please, do NOT forget to edit blog1|blog2 fields according to your subsites.

Reference: https://github.com/W3EDGE/w3-total-cache/wiki/FAQ:-Installation:-Nginx-Web-Server

Hope this helps