W3 Total Cache with Nginx.

  • Posted March 12, 2014

I get this Nginx related error when installing W3 Total Cache Plugin:

FTP credentials don’t allow to write to file /var/www/nginx.conf

W3 Total Cache Error: Files and directories could not be automatically created to complete the installation.

Please execute commands manually

BEGIN W3TC Browser Cache

gzip on; gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

END W3TC Browser Cache

I don’t mind executing the commands manually but the nginx.conf file is not located where W3TC thinks it should be. The file is located at /etc/nginx/nginx.conf. but when I try to copy and paste it in the directory W3TC wants it to be in, I get errors from filezilla saying “open for write: Permission Denied.” so the file refuses to copy to the directory W3 Total Cache wants to make it work.

Any help is very welcome.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Security plugins like iThemes Security or Bulletproof Security may hinder the default file permission. Even other plugins lost their writing permission to .htaccess (for Apache) and nginx.conf (for Nginx). Even you could not see the image which was recently uploaded.

The solution is simple.

  1. Check the directory permission level is 755 (in case WordPress installed in the directory).
  2. Now check the file permission for .htaccess or nginx.conf which is necessary to be 644 Otherwise, you will encounter the error.

You can use FileZilla or cPanel to change file permission level.

Source: DoubtSolver

Ok, this is how I fixed it (same as sunaytamashev explained): <br> <br>1. Copied ‘nginx.conf’ from ‘/etc/nginx’ to ‘/var/www’ and then added the W3 Total Cache code manualy. <br>Refresh, and the error was gone.

I would like some details on the FIX too.

@shanelharder <br>Could you please elaborate a little on the way you got this to work? <br>I am having the same message appear on my site. <br> <br>Can anyone please post a step by step, I am new to the whole VPS config, and not sure where put additional codes and so on. <br> <br>Thanks.

Thanks guys!! I ended up getting it working by copying the nginx.conf file to the new directory under var/www and then adding the new code it asked for. <br> <br>My problem was that I was logging into filezilla with my user profile instead of with root access. I thought I had given myself root privileges but I guess not. <br> <br>Thanks again!!

W3TC writes/creates to an nginx file in the website root, not your main nginx server config file. <br> <br>The error is that your website doesn’t have permissions to create this file. <br> <br>If the website folder is owned by the user the site is running as, it would be able to write to it. You can do this by using sockets. <br> <br>( fastcgi_pass unix:/var/run/php5-fpm/DOMAINNAME.socket;)

How about changing the permissions for the folder just to paste the appropriate file then changing the permissions back to when you are finished? <br>I got Nginx working well with W3TC (also tried with WP Super Cache) and i must say it works wonderfully on a 512MB droplet. <br>I used the ‘easyengine’ script which automated the setup of WP, Nginx and caching methods.