# Nginx index.php forbidden sub-directory only!

**URL:** <https://www.ruby-forum.com/t/nginx-index-php-forbidden-sub-directory-only/209846>\
**Category:** NGINX\
**Created:** [July 24, 2011, 5:33pm UTC](https://www.ruby-forum.com/t/nginx-index-php-forbidden-sub-directory-only/209846 "2011-07-24T17:33:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 24, 2011, 5:33pm UTC](https://www.ruby-forum.com/t/nginx-index-php-forbidden-sub-directory-only/209846/1 "2011-07-24T17:33:36Z")

</div>

## Hello, 'm using nginx 1.0.4 + php-fpm + wordpress. my setup works fine. but when i try access to [http://example.com/wp-admin/](http://example.com/wp-admin/) it give me 403 error and I access [http://example.com/wp-admin/index.php](http://example.com/wp-admin/index.php) works fine, even [http://example.com/](http://example.com/) also works fine. Error log :

## 2011/07/24 21:50:38 [error] 29939#0: \*35 “/home/example/blog/public\_html/wp-admin/index.php” is forbidden (13: Permission denied), client: 125.234.x.x, server: loopback.info, request: “GET /wp-admin/ HTTP/1.1”, host: “[example.com](http://example.com)”

## And my config:

upstream example {  
server unix:/dev/shm/example.sock;

```
server {
        listen 80;
        server_name example.com;
        root /home/example/blog/public_html;
        index index.php;
        access_log /home/example/blog/logs/access.log;
        error_log /home/example/blog/logs/error.log;

        location ~ /\.ht {
         deny all;
        }
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass example;
        include fastcgi_params;
    }

 location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

```

}

–  
Best regards,  
Mr.Hien

---

<div class="post-metadata">

**Author:** ![MrSHien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e79b87/32.png) [@MrSHien](https://www.ruby-forum.com/u/MrSHien)\
**Post date:** [July 24, 2011, 8:00pm UTC](https://www.ruby-forum.com/t/nginx-index-php-forbidden-sub-directory-only/209846/2 "2011-07-24T20:00:16Z")

</div>

Solved by remove " open\_file\_cache max=5000 inactive=20s;" from main  
config file.  
But someone can explain what problem caused.  
Maybe bug?  
Access URL [http://example.com/wp-admin/index.php](http://example.com/wp-admin/index.php) works fine  
While [http://example.com/wp-admin/](http://example.com/wp-admin/) give 403

Permission for wp-admin/index.php is 400, when I try chmod to 444,  
problem solved. I running nginx in OpenVZ.
