"Unable to open primary script: /usr/share/webapps/roundcubemail/webmail/index.php (No such file or directory)"

"Unable to open primary script: /usr/share/webapps/roundcubemail/webmail/index.php (No such file or directory)"

我已经根据 this archlinux wiki 使用 nginx 配置了 roundcubemail。

当我访问 /webmail using: https://mail.hackeac.com/webmail 页面(在浏览器中)时呈现:"No input file specified" 当我检查登录 /var/log/nginx/roundcubemail_error.log 我看到

2017/12/11 13:44:10 [error] 5827#5827: *1 "/usr/share/webapps/roundcubemailwebmail/index.html" is not found (2: No such file or directory), client: 169.255.184.153, server: mail.hackeac.com, request: "GET /webmail/ HTTP/2.0", host: "mail.hackeac.com"
2017/12/11 13:44:19 [error] 5827#5827: *1 "/usr/share/webapps/roundcubemailwebmail/index.html" is not found (2: No such file or directory), client: 169.255.184.153, server: mail.hackeac.com, request: "GET /webmail/ HTTP/2.0", host: "mail.hackeac.com"

Nginx 配置:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name mail.hackeac.com;

    ssl_certificate /etc/letsencrypt/live/hackeac.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/hackeac.com/privkey.pem;

    location /webmail {
        alias /usr/share/webapps/roundcubemail;
        access_log /var/log/nginx/roundcube_access.log;
        error_log /var/log/nginx/roundcube_error.log;
# Favicon
        location ~ ^/webmail/favicon.ico$ {
            root /usr/share/webapps/roundcubemail/skins/classic/images;
            log_not_found off;
            access_log off;
            expires max;
        }
# Robots file
        location ~ ^/webmail/robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }
# Deny Protected directories
        location ~ ^/webmail/(config|temp|logs)/ {
            deny all;
        }
        location ~ ^/webmail/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
            deny all;
        }
        location ~ ^/webmail/(bin|SQL)/ {
            deny all;
        }
# Hide .md files
        location ~ ^/webmail/(.+\.md)$ {
            deny all;
        }
# Hide all dot files
        location ~ ^/webmail/\. {
            deny all;
            access_log off;
            log_not_found off;
        }
#Roundcube fastcgi config
        location ~ /webmail(/.*\.php)$ {
            include fastcgi.conf;
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            fastcgi_split_path_info ^/webmail/(.+\.php)(/.*)$;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/share/webapps/roundcubemail$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PHP_VALUE open_basedir="/tmp/:/var/cache/roundcubemail:/usr/share/webapps/roundcubemail:/etc/webapps/roundcubemail:/usr/share/pear/:/var/log/roundcubemail";
        }
    }
}

或者(更好的缩进)Here.

请帮忙。

您正在使用 fastcgi_param SCRIPT_FILENAME /usr/share/webapps/roundcubemail$fastcgi_script_name; 来计算脚本文件的路径。使用 $request_filename 更简单,它使用 rootalias 指令计算正确的值。

例如:

location /webmail {
    alias /usr/share/webapps/roundcubemail;
    ...
    location ~ \.php$ {
        include fastcgi.conf;
        ...
        fastcgi_param SCRIPT_FILENAME $request_filename;
    }
}

详情见this document