While developing apps running on Nginx, sometimes you may face this kind of error:
open() “/var/cache/nginx/” failed (13: Permission denied) while reading upstream error.
Investigating Nginx logs will show you something like this:
2015/07/25 11:37:44 [crit] 27955#0: *5607 open() "/var/cache/nginx/fastcgi_temp/7/01/0000000017" failed (13: Permission denied) while reading upstream, client: 220.127.116.11, server: yoursite.com, request: "GET /wp-admin/admin.php?page=theme_options HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "yoursite.com", referrer: "http://yoursite.com/wp-admin/themes.php"
What causes the issue?
Most of the time, it’s caused by wrong file permissions or wrong ownership of the files/directories. When this happens, Nginx can’t read and write into those directories, and the result is that your information can not be displayed correctly.
How can you fix it?
The fix for this issue is simple. Try to change the owner of the cache directory:
chown nginx.nginx /var/cache/nginx/ -R
or if you are running Nginx as Apache user (nobody):
chown nobody.nobody /var/cache/nginx/ -R
If that doesn’t work, try removing the directories inside /var/cache/nginx/. Then, restart Nginx and it will automatically create the directories again:
service nginx restart
- How to run CGI scripts using Thttpd + Nginx
- How to Configure Nginx + CDN to Serve Cross Domain Web Fonts
- How to Configure Nginx FASTCGI Cache
- Understanding Common HTTP Status Codes
- How To Customize Your Nginx Server Name
- How to Set Up a Self Signed SSL Certificate on Nginx
- How to install Pimcore on Ubuntu
- Install LiteCart on Ubuntu 14.04 with Nginx, PHP-FPM and MySQL
- How to install Symfony 3 Framework with Nginx on Ubuntu 14.04
- How to install Sylius on Debian 8