W3 Total Cache with Nginx.

March 12, 2014 5.1k views
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.
7 Answers
How about changing the permissions for the folder just to paste the appropriate file then changing the permissions back to when you are finished?
I got Nginx working well with W3TC (also tried with WP Super Cache) and i must say it works wonderfully on a 512MB droplet.
I used the 'easyengine' script which automated the setup of WP, Nginx and caching methods.
W3TC writes/creates to an nginx file in the website root, not your main nginx server config file.

The error is that your website doesn't have permissions to create this file.

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.

( fastcgi_pass unix:/var/run/php5-fpm/DOMAINNAME.socket;)
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.

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.

Thanks again!!
Could you please elaborate a little on the way you got this to work?
I am having the same message appear on my site.

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.

I would like some details on the FIX too.
Ok, this is how I fixed it (same as sunaytamashev explained):

1. Copied 'nginx.conf' from '/etc/nginx' to '/var/www' and then added the W3 Total Cache code manualy.
Refresh, and the error was gone.

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

Have another answer? Share your knowledge.