简体   繁体   中英

create a block in nginx for symfony2

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM