【发布时间】:2018-02-06 19:12:44
【问题描述】:
我有一个处理不同“网站”的配置,主根处理对主 url 的请求,我为它指定了一个特定的路径,在另一个位置 /mailtracker 我处理不同的应用程序并将其指向不同的目录。我的问题是 php-fpm 没有找到第二个位置。
基本上我希望有几个位置指向不同的根。
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/sites/dorero/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /mailtracker {
alias /var/www/sites/mailtracker/web/;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 192.168.10.3:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
location ~ ^/(index|app|app_dev|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 192.168.10.3:9000;
# # With php5-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
我尝试指定别名 /var/www/sites/mailtracker/web/ 的路径而不是 $document_root,但没有成功。
从 php-fpm 到这个配置的输出说:
192.168.10.4 - 06/Feb/2018:19:04:49 +0000 "GET /mailtracker/index.php" 404
【问题讨论】: