1

I need to have my symfony app installed on the same domain as other webapps so I wanted it to sit in /dev/symfony_app path

I tried to use NginX Friendly PHP Framework but solutions from there do not work.

I have such nginx config and it does not work at all too. there is some problem with paths, nor root neither alias directive work for me.

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

nginx error log:

request http://domain.com/dev/symfony_app/

2013/06/23 11:25:31 [error] 22549#0: *668 
"/home/.../public_html/web/dev/symfony_app/index.php"
is not found (2: No such file or directory), client: *,
server: domain.com, request: "GET /dev/symfony_app/ HTTP/1.1", host: "domain.com"

request https://domain.com/dev/symfony_app

2013/06/23 11:25:37 [error] 22549#0: *668
FastCGI sent in stderr: "Primary script unknown" while 
reading response header from upstream, client: *, server: domain.com,
request: "GET /dev/symfony_app HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php-fpm.sock:", host: "domain.com"

request https://domain.com/dev/symfony_app/app_dev.php

2013/06/23 11:27:06 [error] 22549#0: *797 
FastCGI sent in stderr: "Primary script unknown" while 
reading response header from upstream, client: *, server: domain.com, 
request: "GET /dev/symfony_app/app_dev.php HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php-fpm.sock:", host: "domain.com"
4

1 回答 1

1

那么,你的路径中的点在做什么?您不能有一个名称为三个点的目录(至少这对我来说是新的)。来自 nginx 的错误消息在这方面非常具体。这条路不存在。

server {
    listen 80;
    server_name _;
    root /home/public_html/web;

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

这应该够了吧。

Symfony 安装的索引文件的绝对本地路径必须是/home/public_html/web/dev/symfony_app/index.php. 请求http://example.com/dev/symfony_app将映射上述位置。

我希望这会有所帮助,否则请发表评论并描述还有什么问题。

于 2013-06-23T15:16:51.740 回答