我想在web服务器上创建一个子目录,system
为其他文件夹的后端提供服务,但我遇到了一些困难。如何使用Nginx别名从其他目录加载PHP?
服务器配置应该将system
转换为/srv/www/xxx/backend/web
的index.php
,本质上system
应该别名到另一个目录的索引。
我有一个配置,如:
location /system {
alias /srv/www/xxx/backend/web;
rewrite ^(.*) /index.php?r=$1;
return 200 $document_root$fastcgi_script_name;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location/{
rewrite /(.*) /index.php?r=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
我已经试过无数次的迭代(包括使用root
),但即使我可以得到:
return 200 $document_root$fastcgi_script_name;
给我:
/srv/www/xxx/backend/web/index.php
我已经vi'ed到这个文件,以确保它的工作,当我拿出回报wget给了我一个404.我相信我错过了一些非常简单的事情。
有人能帮我理解什么是错的吗?
@XavierLucas哎呀,所以我做了,坏的副本 – Sammaye 2014-11-24 12:40:05
噢好吧。你在错误日志中有什么? – 2014-11-24 12:40:58
@XavierLucas nout,它只是有“进程启动”,就是它 – Sammaye 2014-11-24 12:41:28