Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been having trouble getting a php script to work with nginx. Invoking the script my-url:90/useraccessauthorization/useraccessauthorization.php gives me a 404 error.

Below are my configuration details. Could someone please let me know what I am missing? Thanks in advance.

Edit: I should also mention that running "/etc/init.d/nginx reload" gives me the result:

Reloading nginx configuration: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2012/05/10 16:07:13 [warn] 18214#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 2012/05/10 16:07:13 [emerg] 18214#0: open() "/var/run/nginx.pid" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed

/etc/nginx/sites-available/default :

server {
    listen   90;
    root /usr/share/nginx/www;
    index index.html index.htm;
    access_log  /var/log/nginx/top-secret-project.access.log;
    server_name localhost;

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

    location /doc {
          root /usr/share;
          autoindex on;
          allow 127.0.0.1;
          deny all;
    }
}

server {
          listen 90;
          listen my-url:90;
          server_name my-url;

          access_log  /var/log/nginx/saba.access.log;

          location /assets/ {
                  autoindex on;
                  alias /home/kkaisare/Workspaces/top_secret_project/client/web/assets/;
          }

          location /private_content_server/ {
                  alias /home/kkaisare/Workspaces/top_secret_project/store/content/private_content_server/;
                  autoindex on;
          }

          location /production_content_server/ {
                  alias /home/kkaisare/Workspaces/top_secret_project/store/content/production_content_server/;
                  autoindex on;
          }

          include /etc/nginx/fastcgi_php;
  }

/etc/nginx/fastcgi_php:

location /useraccessauthorization/\.php$ {
    fastcgi_pass   unix:/var/run/php-fastcgi/php.sock;
    fastcgi_param  SCRIPT_FILENAME  /home/kkaisare/Workspaces/top_secret_project/store/content/production_content_server/$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
}
share|improve this question
add comment

2 Answers

First of all you really need to fix your configuration issues. If you're not running this as root then don't bother trying to change into a different user. Though, if you're binding to port 90 then you actually need to start as root, so either bind to a port higher than 1024 or start it as root and let nginx drop the privilege through the user directive.

Secondly your pid file, since you're not starting as root you probably need to ensure that your actual user has access to read the pid file created by your init script. Until you fix this issue you cannot reload your config dynamically.

Finally, when the above is fixed. Then change your location from

location /useraccessauthorization/\.php$ {

to

location ~ ^/useraccessauthorization/.+\.php$ {
share|improve this answer
add comment

what does your /etc/nginx/nginx.conf look like? From the looks of it your errors are because you are not reloading nginx as either the owner or a superuser.

Double check the permissions on those files that they are owned by the nginx user (www/www usually), and also the user directive error would get fixed by a sudo /etc/init.d/nginx reload.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.