我在处理子目录。我想要“巴比伦/网络邮件”去我的雨环网络邮件客户端。
location ^~ /webmail {
root /srv/rainloop/public_html;
try_files $uri $uri/ /webmail/index.php?$query_string;
access_log /srv/rainloop/logs/access.log;
error_log /srv/rainloop/logs/error.log;
index index.php;
access_log /var/log/nginx/scripts.log scripts;
location ~ \.php$ {
#fastcgi_index index.php;
#fastcgi_split_path_info ^(.+\.php)(.*)$;
#fastcgi_keep_conn on;
#include /etc/nginx/fastcgi_params;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php;
#include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location ^~ /webmail/data {
deny all;
}
}不过,这
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;根本不起作用。它打印出来:目录结构中不存在该文件,但是:/srv/ /srv/rainloop/public_html/webmail/index.php;/public_html/index.php
fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php;P.S.:硬编码后,我完全没有发现任何错误,但是这个页面是空白的,有一些雨环代码源代码。
发布于 2017-08-15 20:40:56
文件的路径是通过将root的值连接到URI来计算的。URI包含/webmail/index.php,否则它将与location块不匹配。
您可能打算使用alias而不是root,因为该指令在计算文件路径时删除前缀location的值。详情请参见本文件。
location ^~ /webmail {
alias /srv/rainloop/public_html;
if (!-e $request_filename) { rewrite ^ /webmail/index.php last; }
...
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}避免在同一块中使用try_files和alias,原因是这一长期问题,并在使用if时请参阅这种谨慎。对$request_filename值使用SCRIPT_FILENAME。
https://stackoverflow.com/questions/45696499
复制相似问题