2016-01-13 31 views
1

我在OVH serwer上的nginx实例有问题。Symfony,nginx和“未找到文件”。

当我进入我的页面时,我有错误“File not found。”。

的/ etc/nginx的/网站可用/ defaul 从官方Symfony的配置: http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html#nginx

server { 
    server_name 51.255.193.179; 
    root /root/www/harccal/web; 

    location/{ 
     try_files $uri /app.php$is_args$args; 
    } 
    # DEV 
    location ~ ^/(app_dev|config)\.php(/|$) { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
    } 
    # PROD 
    location ~ ^/app\.php(/|$) { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
     internal; 
    } 

    error_log /var/log/nginx/project_error.log; 
    access_log /var/log/nginx/project_access.log; 
} 

error_log中:

2016/01/13 23:57:04 [crit] 9372#0: *9 stat() "/root/www/harccal/web/" failed (13: Permission denied), client: 89.70.84.185, server: 51.255.193.179, request: "GET/HTTP/1.1", host: "51$ 
2016/01/13 23:57:04 [crit] 9372#0: *9 realpath() "/root/www/harccal/web" failed (13: Permission denied), client: 89.70.84.185, server: 51.255.193.179, request: "GET/HTTP/1.1", host: $ 
2016/01/13 23:57:04 [error] 9372#0: *9 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 89.70.84.185, server: 51.255.193.179, request: "$ 

炳:

:~/www/harccal# ls -al 
total 1332 
drwxr-xr-x 8 root root 4096 sty 13 22:02 . 
drwxr-xr-x 3 root root 4096 sty 13 21:51 .. 
drwxr-xr-x 6 root root 4096 sty 13 22:24 app 
drwxr-xr-x 2 root root 4096 sty 13 22:13 bin 
-rw-r--r-- 1 root root 2669 sty 13 21:51 composer.json 
-rw-r--r-- 1 root root 67193 sty 13 22:13 composer.lock 
-rwxr-xr-x 1 root root 1248055 sty 13 22:02 composer.phar 
drwxr-xr-x 8 root root 4096 sty 13 21:51 .git 
-rw-r--r-- 1 root root  80 sty 13 21:51 .gitignore 
-rw-r--r-- 1 root root  85 sty 13 21:51 README.md 
drwxr-xr-x 4 root root 4096 sty 13 21:51 src 
drwxr-xr-x 16 root root 4096 sty 13 22:24 vendor 
drwxrwxr-x 7 root root 4096 sty 13 22:03 web 

的/ etc/nginx/nginx.conf

user www-data; 
worker_processes auto; 
pid /run/nginx.pid; 

events { 
     worker_connections 768; 
     # multi_accept on; 
} 

http { 

     ## 
     # Basic Settings 
     ## 

     sendfile on; 
     tcp_nopush on; 
     tcp_nodelay on; 
     keepalive_timeout 65; 
     types_hash_max_size 2048; 
     # server_tokens off; 

     # server_names_hash_bucket_size 64; 
     # server_name_in_redirect off; 

     include /etc/nginx/mime.types; 
     default_type application/octet-stream; 

     ## 
     # SSL Settings 
     ## 

     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 
     ssl_prefer_server_ciphers on; 

     ## 
     # Logging Settings 
     ## 

     access_log /var/log/nginx/access.log; 
     error_log /var/log/nginx/error.log; 

     ## 
     # Gzip Settings 
     ## 

     include /etc/nginx/mime.types; 
     default_type application/octet-stream; 

     ## 
     # SSL Settings 
     ## 

     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 
     ssl_prefer_server_ciphers on; 

     ## 
     # Logging Settings 
     ## 

     access_log /var/log/nginx/access.log; 
     error_log /var/log/nginx/error.log; 

     ## 
     # Gzip Settings 
     ## 

     gzip on; 
     gzip_disable "msie6"; 

     # gzip_vary on; 
     # gzip_proxied any; 
     # gzip_comp_level 6; 
     # gzip_buffers 16 8k; 
     # gzip_http_version 1.1; 
     # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 

     ## 
     # Virtual Host Configs 
     ## 

     include /etc/nginx/conf.d/*.conf; 
     include /etc/nginx/sites-enabled/*; 
} 

我没有更多的日志。或者我不知道什么时候找到它..

回答

3

/root目录默认没有读取权限other用户,这是非常合理的。最有可能的是它具有700权限。

接下来会发生什么 - 您的网络服务器用户www-data尝试读取/root/www/harccal/web中的文件。但链中的第一个目录(/root)不可读取。所以它终止于9 stat() "/root/www/harccal/web/" failed (13: Permission denied)

要使文件可读 - 每个父目录也必须可以遍历。

解决方案:您最好将您的应用程序移动到另一个可由Web服务器用户访问的目录。