4

I'm trying to create a localhost server with nginx. I'm getting a 403 Forbidden on my page. Here's my nginx error log:

2013/03/30 20:39:18 [error] 12161#0: *1 directory index of "/home/mike/Projects/606club/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET /606club/ HTTP/1.1", host: "localhost"

My nginx.conf file:

server {
    listen       80;
    server_name  localhost;

    #for .html sites
    location / {
        root   /home/mike/Projects;
        index  index.html index.htm;
    }

    #for .php sites
    location ~ \.php$ {
            root /home/mike/Projects;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /opt/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

My site at the URLs below gives me the following:

works

http://<myhost>/home/mike/Projects/thoth/index.html

403 Forbidden error

http://<myhost>/home/mike/Projects/606club/index.php

My folders have permissions 755.

1
  • That URL didn't give you a 403 Forbidden error, according to your error message; a different URL did. Mar 31, 2013 at 3:45

3 Answers 3

3

You need to add index.php to your index directive, if you want requests for / to be served by /index.php.

1
  • I added index.php and now I'm getting and an nginx error "An error occured.". In my error log same error.
    – mikeglaz
    Mar 31, 2013 at 18:36
1

Figured it out. Inside /etc/php5/fpm/pool.d/www.conf I had to change

listen = /var/run/php5-fpm.sock

to

listen = 127.0.0.1:9000
0

try

sudo chmod 755 index.php

in my case this works, before this I cant see index.php but can index.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .