我正在尝试在相对 url 上使用 Nginx 设置 roundcube / phpldapadmin / ...,例如:
example.com/roundcube
example.com/phpldapadmin
源代码位于以下文件夹中:
/var/www/roundcube
/usr/share/phpldapadmin
Apache 2.4 一切正常,但我是 Nginx 的新手。我有以下location
内容roundcube
:
location /roundcube/ {
root /var/www;
index index.php;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
哪个工作正常,但以下phpldapadmin
不起作用:
location /phpldapadmin/ {
alias /usr/share/phpldapadmin/htdocs;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
我得到一个403 forbidden
,带有以下日志:
2016/02/07 21:43:33 [错误] 23047#0: *1 "/usr/share/phpldapadmin/htdocs" 的目录索引被禁止,客户端:xxx.xxx.xxx.xxx,服务器:,请求: “GET /phpldapadmin/HTTP/1.1”,主机:“ ”
我检查了权限:
$ namei -om /usr/share/phpldapadmin/htdocs
f: /usr/share/phpldapadmin/htdocs
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root share
drwxr-xr-x root root phpldapadmin
drwxr-xr-x root www-data htdocs
$ ls -l /usr/share/phpldapadmin/htdocs/index.php
-rw-r--r-- 1 root root 20036 Oct 28 17:32 /usr/share/phpldapadmin/htdocs/index.php
我尝试将所有者更改为,:www-data
但没有成功。当我为圆形立方体尝试以下操作时,它不起作用:
location /roundcube/ {
alias /var/www/roundcube;
...
}
我认为这可能是尾随的问题/
或类似问题的问题,但我对 nginx 真的很陌生,所以我找不到它......
基本上,我有相反的问题:https ://stackoverflow.com/questions/31820362/nginx-403-directory-is-forbidden-when-using-root-location