当试图安装nginx / owncloud时,显示“找不到文件”消息

我试图使用nginx作为我的云端安装的networking服务器。 根据本教程 ,我创build了以下configuration文件:

server { listen 59476; server_name mydomain.de; root /home/owncloud/www/; access_log /home/owncloud/log/nginx.access.log; error_log /home/owncloud/log/nginx.error.log debug; client_max_body_size 10G; # set max upload size fastcgi_buffers 64 4K; rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; index index.php; error_page 403 = /core/templates/403.php; error_page 404 = /core/templates/404.php; location = /robots.txt { allow all; log_not_found off; access_log off; } location = /favicon.ico { access_log off; log_not_found off; } location ~ ^/(data|config|\.ht|db_structure\.xml|README) { deny all; } location / { # The following 2 rules are only needed with webfinger rewrite ^/.well-known/host-meta /public.php?service=host-meta last; rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; try_files $uri $uri/ index.php; } location ~ ^(.+?\.php)(/.*)?$ { try_files $1 = 404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$1; fastcgi_param PATH_INFO $2; fastcgi_pass unix:/var/run/php5-fpm.sock; } # Optional: set long EXPIRES header on static assets location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { expires 30d; # Optional: Don't log access to assets access_log off; } } 

但是,当我访问网站http://mydomain.de:59476我只得到错误信息“文件未find。”。 由于我将debugging级别设置为“debugging”,我得到以下广泛的日志文件http://pastebin.com/uy7jHQQs 。 我认为最重要的是

 2013/08/03 17:23:21 [error] 29508#0: *3 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 37.24.146.15, server: mydomain.de, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mydomain.de:59476" 

其中,正如我所理解的nginx,意味着nginx试图执行的文件不存在。 但是日志还说:

 2013/08/03 17:23:21 [debug] 29508#0: *3 fastcgi param: "SCRIPT_FILENAME: /home/owncloud/www/index.php" 

/home/owncloud/www/index.php文件确实存在。

要检查nginx是否能正常工作,我build立了另外一个没有owncloud的网站,一切正常(包括PHP支持),具有以下configuration:

 server { listen 59477; server_name mydomain.net; root /home/born/web/nginx; index index.php; # Logging -- access_log /home/myuser/logs/nginx.access.log; error_log /home/myuser/logs/nginx.error.log notice; # serve static files directly location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { access_log off; expires max; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } } 

和下面的fastcgi_params

 fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param HTTPS $https; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; 

nginx用户有权从“/ home / owncloud / www /”中读取吗? 它是否有权利/var/run/php5-fpm.sock?

检查尝试:

 sudo -u nginx ls /var/run/php5-fpm.sock 

 sudo -u nginx ls /home/owncloud/www/index.php 

并使用ps aux | grep nginx检查它是否真正运行为“nginx”

经过大量的挖掘后,事实certificate,既不是nginx,也没有owncloud的原因,“文件未find”。 我通过停止php5-fpm服务发现了这个问题,该服务将消息从nginx改为502 Bad Gateway。

nginx相应的subprocess作为用户自己的云而不是www-data运行,php5-fpm相应的subprocess作为www-data运行。 添加一个新的使用用户owncloud的新套接字解决了问题。 该消息是“文件未find”,而不是拒绝访问,因为用户不被允许读取目录。

如果遇到同样的原因,请确保nginx访问正确的套接字。

@Marco:谢谢你所有的时间。