首先,提前感谢您的阅读/帮助。我有一台 Nginx 服务器,我正尝试从 /usr/share/squirrelmail 提取 squirrelmail。
squirrelmail 文件夹位于 /usr/share/squirrelmail,该文件夹的所有者和组是 www-data。我已设置一个位置和别名来指向 /test(位于https://brailsford.xyz/测试/) 位于 squirrelmail 文件夹中。但是,页面显示未找到。有什么想法吗?
下面是我网站的 nginx 配置。
server {
listen 443;
server_name brailsford.xyz;
ssl on;
ssl_certificate /etc/ssl/certs/cert_chain.crt;
ssl_certificate_key /etc/ssl/private/brailsford.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
root /data/brailsford.xyz/www;
index index.php index.html index.htm;
location ~ \.php$ {
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_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /data/brailsford.xyz/www;
}
error_log /data/brailsford.xyz/logs/error.log error;
access_log /data/brailsford.xyz/logs/access.log;
location / {
index index.php;
}
location /test {
alias /usr/share/squirrelmail/;
index index.php;
}
}
答案1
对于任何关注此问题的人来说,问题在于路径必须声明两次,一次在位置,一次作为 PHP 的内部位置。这是一个糟糕的解释,以下是代码:
location /webmail {
alias /var/lib/roundcube;
try_files $uri $uri/ /index.php;
index index.php;
location ~ ^/webmail(.+\.php)$ {
include fastcgi_params;
alias /var/lib/roundcube/$1;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/lib/roundcube$1;
fastcgi_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_intercept_errors on;
}
}