【发布时间】:2013-05-28 12:49:47
【问题描述】:
我在这个问题上花了 6 个多小时。
我有 nginx/1.2.7 服务器和 127.0.0.1:9000 上的 php-fpm。 我有基本的 nginx 配置:
server
{
listen 80;
server_name example.org www.example.org;
index index.php index.html;
access_log /srv/www/example.org/logs/access.log;
error_log /srv/www/example.org/logs/error.log;
location /
{
root /var/www/html/example.org/public_html;
try_files $uri $uri/ /index.php;
location ~ \.php$
{
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
而且效果很好!所有 php 文件都可以正常工作。
但我有一些单独的 yii 项目,需要在主根文件夹以外的地方执行。 我在底部添加了这个配置:
/srv/www/example.org/yiitest — 它是 yiitest 项目的根目录(其中包含“受保护”文件夹和其他内容)。 p>
location /yiitest
{
root /srv/www/example.org/yiitest;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$
{
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
但它不起作用。我有“找不到文件”。 我能得到的最大的东西是:example.org/yiitest/ 主页工作正常。 如果我去 example.org/yiitest/site/contact/ 我会找不到文件。 :(
我不明白,如何在服务器的单独子目录中正确设置 yii-project。
【问题讨论】:
-
我也面临着同样的问题。你找到解决办法了吗?
标签: configuration yii nginx subdirectory