无法写入缓存目录 Symfony 3.1

无法写入缓存目录 Symfony 3.1
/var/log/nginx/app.local_error.log:

2018/09/13 11:25:20 [错误] 20627#0: *18 FastCGI 在 stderr 中发送:“PHP 消息:PHP 致命错误:未捕获的 RuntimeException:无法在 /var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:563 中的缓存目录(/var/www/app.local/var/cache/prod)中写入堆栈跟踪:

/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} 投入

/var/www/app.local/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php 在第 563 行”从上游读取响应标头时,客户端:127.0.0.1,服务器:app.local,请求:“GET / HTTP/1.1”,上游:“fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”,主机:“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

试过了但结果是一样的

我该如何修复这个错误?

答案1

将缓存目录的安全上下文设置为public_content_rw_t

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

然后 selinux 将允许对该目录进行写访问。您必须对 symfony 日志目录执行相同操作。

答案2

通过禁用 SELinux 解决。解决方案https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

相关内容