簡體   English   中英

在Nginx中為symfony2創建一個塊

[英]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;
}

我一直在嘗試使此工作正常進行,但無法進行,當我轉到myapp.local時, myapp.local No input file specified. 在日志中,我有:

[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

看起來它正在嘗試訪問/usr/share/nginx/html/app.php ,為什么它在這樣做呢? nginx -v : 1.4.6

信不信由你,經過4個小時的調試,我意識到在server_name語句后,所有關於分號的缺失都是很糟糕的。 多可惜!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM