2
server {
   listen 80; 

   server_name myapp.local
   root /home/jack/Documents/projects/php/myapp/web;

   location / { 
       #try_files $uri $uri/ /app_dev.php?$query_string;
       #try_files $uri /app_dev.php$is_args$args;
       try_files $uri @rewriteapp;
   }   

    location @rewriteapp {
        rewrite ^(.*)$ /app_dev.php/$1 last;
    }   

    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }   

   access_log /var/log/nginx/myapp-access.log;
   error_log /var/log/nginx/myapp-error.log;
}

I've been trying to make this work but I couldn't and when I go to myapp.local I got No input file specified.. In the logs I have:

[error] 6867#0: *1 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/html/app.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: myapp.local, request: "GET /app.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "myapp.local"

UPDATE

It looks like it's trying to access /usr/share/nginx/html/app.php, why in the world is it doing that? nginx -v : 1.4.6

2
  • Are you sure that this file is getting called, /usr/share/nginx/html/app.php seems to imply that your webserver is calling a different file using a different root. Maybe a file that is defining listen 80 default_server; Commented Mar 7, 2015 at 6:04
  • I set the port number to 8888 to make sure: myapp.local:8888 gives me exactly the same error and myapp.local gives this 403 Forbidden. But I understand your question. Commented Mar 7, 2015 at 7:21

1 Answer 1

4

Believe it or not guys, after 4 hours of debugging I realized that it was all about a poor missing semicolon after server_name statement. What a shame!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.