我需要将我的symfony应用程序安装在与其他webapps相同的域中,所以我希望它位于/ dev / symfony_app路径
我尝试使用NginX Friendly PHP Framework但是那里的解决方案不起作用。
我有这样的nginx配置,它根本不起作用。路径有问题,根也没有别名指令对我有效。
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错误日志:
请求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"
请求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"
请求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"
答案 0 :(得分: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
的请求将映射上述位置。
我希望这会有所帮助,否则请发表评论并描述其他问题。