Symfony,nginx和"文件未找到。"

时间:2016-01-13 23:00:49

标签: symfony nginx

我在OVH serwer上遇到nginx实例的问题。

当我转到我的页面时,我发现错误"找不到文件。"。

的/ 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: "$

PREM:

:~/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/*;
}

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

1 个答案:

答案 0 :(得分:3)

默认情况下,

/root目录没有other个用户的读取权限,这非常合理。并且很可能它具有700权限。

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

结束

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

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