# Nginx cache opendir failed

**URL:** <https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932>\
**Category:** NGINX\
**Created:** [May 19, 2013, 5:52pm UTC](https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932 "2013-05-19T17:52:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [May 19, 2013, 5:52pm UTC](https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932/1 "2013-05-19T17:52:06Z")

</div>

Hi

On a Freebsd 9.1 machine  
Nginx 1.4.1

opendir() “/var/cache/www/nginx2” failed (13: Permission denied)

microcache dir :  
drwxr-x–x 3 root wheel 512 May 19 17:05 /var/cache  
drwxr-xr-x 3 www www 512 May 19 17:06 /var/cache/www  
drwx------ 2 www www 512 May 19 17:06 nginx2

How to correct this ?

Thanks.

---

<div class="post-metadata">

**Author:** ![istos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@istos](https://www.ruby-forum.com/u/istos)\
**Post date:** [May 20, 2013, 11:11am UTC](https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932/2 "2013-05-20T11:11:32Z")

</div>

SOLVED:

Just chmod 7777 ( 4 seven) /var/cache/www , the parent directory of the  
nginx cache and voil, it works.

Le 19 mai 2013 17:51, Ronald Van A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a crit :

---

<div class="post-metadata">

**Author:** ![istos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@istos](https://www.ruby-forum.com/u/istos)\
**Post date:** [May 20, 2013, 11:20am UTC](https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932/3 "2013-05-20T11:20:18Z")

</div>

So, you need to ensure all files can only be deleted by the owner, all  
files created in the directory are in the same group as the directory  
and, to the best of my knowledge, setuid is meaningless.

Ah, I see that it’s a freebsd machine… setgid is the default  
functionality on that OS.

This may work, but a basic understanding of file permissions will  
produce a more workable solution. Who runs the web server? That’s who  
you need to set access up for.

Steve

---

<div class="post-metadata">

**Author:** ![istos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@istos](https://www.ruby-forum.com/u/istos)\
**Post date:** [May 20, 2013, 11:27am UTC](https://www.ruby-forum.com/t/nginx-cache-opendir-failed/234932/4 "2013-05-20T11:27:19Z")

</div>

the Web server is run by “www” , and owns the parent directory of the  
cache.

Le 20 mai 2013 11:19, Stev e Holdoway [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a crit :
