【问题标题】:Symfony2 Ngix 404 error and RuntimeException: Unable to write in the logs directorySymfony Nginx 404错误和RuntimeException:无法写入日志目录
【发布时间】:2014-03-18 14:05:29
【问题描述】:

我用 php fpm 安装了 Nginx,并进行了配置,在我下载 Symfony2 之前,一切似乎都运行良好。当我尝试访问 app.php 时,我得到服务器返回了“404 Not Found”。错误,当我尝试访问 app_dev.php 时,我得到 RuntimeException: Unable to write in the logs 目录,因为我在http://symfony.com/doc/current/book/installation.html 教程中尝试的错误明确说明了权限问题,提供了 ACL 解决方案,但这没有帮助,事件在 app/console、web/app_dev.php、web/app.php 中尝试了“unmask(0000)”,也没有成功。 我的 nginx 设置:

upstream phpfcgi {
    #server 127.0.0.1:9000;
    server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}
server {
    listen 80;

    server_name localhost;
    root /home/antanas/public_html/demo/web;

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

    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}

这个问题的原因可能是什么?

【问题讨论】:

    标签: symfony nginx


    【解决方案1】:

    如果您收到应用程序无法写入日志的错误,您需要确保 Symfony 日志对 Web 用户是可写的。

    转到 Symfony/app/logs。你会看到dev.logprod.log。这两个文件应该是网络用户可写的。

    为了测试,你可以给每个人写权限chmod a+w dev.log,看看是否能解决问题。如果是这样,您可能需要探索更好的日志权限。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-20
      • 2012-08-24
      • 1970-01-01
      • 2017-04-06
      • 1970-01-01
      • 1970-01-01
      • 2019-09-27
      • 1970-01-01
      相关资源
      最近更新 更多