1
/var/log/nginx/app.local_error.log: 

2018/09/13 11:25:20 [error] 20627#0: *18 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RuntimeException: Unable to write in the cache directory (/var/www/app.local/var/cache/prod) in /var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:563 Stack trace:

/var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(476): Symfony\Component\HttpKernel\Kernel->buildContainer()

/var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(117): Symfony\Component\HttpKernel\Kernel->initializeContainer()

/var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(166): Symfony\Component\HttpKernel\Kernel->boot() 3 /var/www/app.local/web/app.php(18): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))

{main} thrown in

/var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php on line 563" while reading response header from upstream, client: 127.0.0.1, server: app.local, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "app.local"

[user@localhost app.local]$ ls -la total 2080 drwxrwxrwx. 11 user user 4096 Sep 13 09:09 . drwxrwxrwx. 6 user user 70 Sep 13 08:17 .. drwxrwxrwx. 4 user user 4096 Sep 13 08:17 app drwxrwxrwx. 2 user user 47 Sep 13 08:37 bin -rwxrwxrwx. 1 user user 639 Sep 13 09:15 bower.json -rwxrwxrwx. 1 user user 66 Sep 13 08:17 .bowerrc -rwxrwxrwx. 1 user user 3612 Sep 13 08:17 composer.json -rwxrwxrwx. 1 user user 144489 Sep 13 08:17 composer.lock -rwxrwxrwx. 1 user user 1875611 Sep 13 08:22 composer.phar drwxrwxrwx. 8 user user 4096 Sep 13 08:17 .git -rwxrwxrwx. 1 user user 391 Sep 13 08:17 .gitignore -rwxrwxrwx. 1 user user 5586 Sep 13 08:17 gulpfile.js -rwxrwxrwx. 1 user user 1065 Sep 13 08:17 LICENSE drwxrwxrwx. 548 user user 16384 Sep 13 09:15 node_modules -rwxrwxrwx. 1 user user 965 Sep 13 08:17 package.json -rwxrwxrwx. 1 user user 978 Sep 13 08:17 phpunit.xml.dist -rwxrwxrwx. 1 user user 10647 Sep 13 08:17 README.md drwxrwxrwx. 3 user user 34 Sep 13 08:17 src drwxrwxrwx. 2 user user 21 Sep 13 08:17 upload drwxrwxrwx+ 4 user user (or nginx) 85 Sep 13 08:37 var drwxrwxrwx. 38 user user 4096 Sep 13 08:37 vendor drwxrwxrwx. 5 user user 4096 Sep 13 09:16 web 

CentOS 7.2.511 Nginx 1.8.0 PHP 7.0.31 Symfony 3.1

Tried it but got the same result

How can I fix this error?

3
  • So what is your question? Something that ends with a "?" ... Commented Sep 13, 2018 at 19:02
  • @Pierre.Vriens How can I fix this error? Commented Sep 13, 2018 at 19:43
  • Now we have a real question .... Commented Sep 13, 2018 at 20:16

2 Answers 2

0

Set the security context for the cache directory to public_content_rw_t:

chcon -R -t public_content_rw_t /var/www/aapp.local/var/cache/prod 

Then selinux will allow write access to the directory. You will have to do the same for the symfony log directory.

4
  • where you been? thx a lot! Commented Sep 17, 2018 at 12:51
  • You should also clean up your permissions. 777 is just wrong, even with selinux in place. Commented Sep 17, 2018 at 12:58
  • thx its just the local project Commented Sep 17, 2018 at 13:21
  • didn't work for some reason. disabling selinux did help. Commented Jun 1, 2019 at 11:59
0

Solved by disabling SELinux. The solution https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

2
  • disabling selinux is not a solution, it's a workaround. Just set the correct security context for the directory. Commented Sep 17, 2018 at 12:18
  • that's the exact workaround I needed as a dev in order to be unblocked while sysadmin is away. +1 to make it even. However, this answer should be made complete by showing the instructions from the link. Commented Jun 1, 2019 at 12:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.