views:

53

answers:

2

I have setup nginx 0.7.67 on Ubuntu10.10 along with php-cli . I'm trying to get my front-controller based PHP framework to run, but all pages except index.php give a 403 error.

Ex :

  1. http://mysite.com/styles/style.css - 403 Forbidden
  2. http://mysite.com/scripts/script.css - 403 Forbidden
  3. http://mysite.com/index.php - Works

My /etc/nginx/sites-enabled/default is as follows

server {
    listen          80;
    server_name     mysite.com;

    access_log      /var/log/nginx/access.log;
    error_log       /var/log/nginx/error.log warn;

    index           index.php index.html;
    root        /full/path/to/public_html;

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


    location ~ index.php {
            include     /etc/nginx/fastcgi_params;
            keepalive_timeout 0;
            fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_pass    127.0.0.1:9000;
    }

}

Any suggestions on how to fix the above?

PS: This is the entry from the error log

2010/10/14 19:56:15 [error] 3284#0: *1 open() "/full/path/to/public_html/styles/style.css" 
failed (13: Permission denied), client: 127.0.0.2, server: quickstart.local, 
request: "GET /styles/style.css HTTP/1.1", host: "mysite"
A: 

Try this in your location line:

location ~* ^.+\.(js|css|png|jpg|jpeg|gif|ico|html)$ {

or

location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|html)$ {
Vantomex
It still gives the same error with both the options
Adil
error log says 2010/10/14 19:56:15 [error] 3284#0: *1 open() "/home/adil/NetBeansProjects-old/CrowdSourcedWeb/applications/csw/web/styles/style.css" failed (13: Permission denied), client: 127.0.0.2, server: quickstart.local, request: "GET /styles/style.css HTTP/1.1", host: "quickstart.local"
Adil
A: 
    server {
        listen          80;
        server_name     mysite.com;

        access_log      /var/log/nginx/access.log;
        error_log       /var/log/nginx/error.log warn;

        index           index.php index.html;
        root        /full/path/to/public_html;

} <--- you forgot this one

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


        location ~ index.php {
                include     /etc/nginx/fastcgi_params;
                keepalive_timeout 0;
                fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_pass    127.0.0.1:9000;
        }

    }

you have to close server{} before defining the location.

or change the owner of the files to www-data or apache if you don't have access to the files.

Maarten
The location tag must be inside the server tag.
Adil
that's strange, in my situation it works with closing server{} before defining a location. But i'm glad you found the solution!
Maarten
Maarten. Just to explain my comment above, the reason i said that is because nginx complains. Its "illegal" to keep the location tag outside the server tag. Maybe you should look into your conf again, to see precisely why it does that. Good to know. And, thanks for helping.
Adil