我正在尝试使用 nginx + php-fpm 在我的 raspberry pi 上为 Owncloud 提供服务。我正在使用自定义安装路径/mnt/usbstorage/Documents/owncloud
,并且我想使用 url 访问 owncloud http://myserver/owncloud/
。
我已经配置了位置,并且可以访问index.php
。但是,CSS 和 JS 文件尚未加载。
配置nginx
如下(我省略了一些部分,以保持最少):
upstream php-handler {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name _;
location ^~ /owncloud {
alias /mnt/usbstorage/Documents;
client_max_body_size 10G;
fastcgi_buffers 64 4K;
gzip off;
index /owncloud/index.php;
error_page 403 /owncloud/core/templates/403.php;
error_page 404 /owncloud/core/templates/404.php;
location /owncloud {
rewrite ^ /owncloud/index.php$uri;
}
location ~ ^/owncloud/(?:index|remote|public|cron|core|ajax|update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
}
location ~* \.(?:css|js)$ {
try_files $uri /owncloud/index.php$uri$is_args$args;
access_log off;
}
location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
try_files $uri /owncloud/index.php$uri$is_args$args;
access_log off;
}
}
}
例如,当我尝试访问 CSS 文件时,从 Nginx 日志中可以看到正在location
使用正确的块,甚至也是$uri
正确的。但是,当尝试获取文件时,Nginx 使用不同的路径(参见带有 的行http filename
):
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: "/owncloud"
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/"
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console)"
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:index|remote|public|cron|core|ajax|update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[3
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:updater|ocs-provider)(?:$|/)"
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud(.*\.(?:css|js))$"
2016/09/16 22:31:59 [debug] 31460#0: *2274 using configuration "^/owncloud(.*\.(?:css|js))$"
2016/09/16 22:31:59 [debug] 31460#0: *2274 http script capture: "/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 trying to use file: "/core/css/styles.css" "/mnt/usbstorage/Documents/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 http script var: "/owncloud/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 trying to use file: "/owncloud/core/css/styles.css" "/mnt/usbstorage/Documents/owncloud/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 try file uri: "/owncloud/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 http filename: "/mnt/usbstorage/Documents/core/css/styles.css"
2016/09/16 22:31:59 [error] 31460#0: *2274 open() "/mnt/usbstorage/Documents/core/css/styles.css" failed (2: No such file or directory), client: 192.168.1.29, server: _, request: "
2016/09/16 22:31:59 [debug] 31460#0: *2274 http finalize request: 404, "/owncloud/core/css/styles.css?" a:1, c:1
2016/09/16 22:31:59 [debug] 31460#0: *2274 http special response: 404, "/owncloud/core/css/styles.css?"
2016/09/16 22:31:59 [debug] 31460#0: *2274 internal redirect: "/owncloud/core/templates/404.php?"
有什么想法为什么nginx
要使用这个没有的其他路径owncloud/
吗?