antanas_sepikas
antanas_sepikas

Reputation: 5704

Symfony2 Ngix 404 error and RuntimeException: Unable to write in the logs directory

I installed Nginx with php fpm, and configured, everything seemed to be working fine until I downloaded Symfony2. When I try to access app.php I get The server returned a "404 Not Found". error, and when I try to access app_dev.php I get RuntimeException: Unable to write in the logs directory, as the error cleary stated permisions problem i tryed in http://symfony.com/doc/current/book/installation.html tutorial offered solutions with ACL, but that didn't helped, event tryed "unmask(0000)" in app/console, web/app_dev.php, web/app.php, no success either. My nginx setup:

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;
    }
}

What may be the cause of this problem?

Upvotes: 0

Views: 5418

Answers (1)

Sehael
Sehael

Reputation: 3736

If you get the error that the application is unable to write to the logs, you need to make sure that the Symfony logs are writable for the web user.

Go to Symfony/app/logs. and you will see dev.log and prod.log. These two files should be writable by the web user.

To test, you can give everyone write access chmod a+w dev.log and see if that solves the issue. If it does, you may want to explore better permissions for the logs.

Upvotes: 2

Related Questions