生产Symfony应用程序保持错误权限或404

时间:2016-08-14 00:54:22

标签: php symfony caching nginx doctrine

我正在尝试在AWS实例上设置基于Symfony的新网站。到目前为止,我已经将它推向Capifony的制作,而且那部分工作正常。

当我尝试访问该网站时,出现以下错误

致命错误:未捕获InvalidArgumentException:目录" / var / www / myapp / releases / 20160813225423 / app / cache / prod / annotations"是不可写的。在/var/www/myapp/releases/20160813225423/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php:92堆栈跟踪:#0 / var / www / myapp / releases / 20160813225423 / vendor / doctrine /cache/lib/Doctrine/Common/Cache/FilesystemCache.php(37):Doctrine \ Common \ Cache \ FileCache-> __ construct(' / var / www / myapp / re ...', ' .doctrinecache ....',2)#1 /var/www/myapp/releases/20160813225423/app/cache/prod/appProdProjectContainer.php(1109):Doctrine \ Common \ Cache \ FilesystemCache - > __ construct(' / var / www / myapp / re ...')#2 /var/www/myapp/releases/20160813225423/app/bootstrap.php.cache(2222):appProdProjectContainer - > getAnnotationReaderService()#3 /var/www/myapp/releases/20160813225423/app/cache/prod/appProdProjectContainer.php(15229):Symfony \ Component \ DependencyInjection \ Container-> get(' annotation_read。 ..')#4 /var/www/myapp/releases/20160813225423/app/cache/prod/appProdProjectContainer.php(15220):appProdProjectContainer- in / var / www / myapp / releases / 20160813225423 / vendo第92行的r / doctrine / cache / lib / Doctrine / Common / Cache / FileCache.php

然后我将目录的权限修复为777(这发生在缓存中的几个目录中......不确定我是否正确执行...

每次推送到生产时都会重建缓存,因为文件夹不是共享的。

修复这些错误后,我收到了新的错误

"糟糕!发生错误

服务器返回" 404 Not Found"。

有些东西坏了。发生此错误时,请告诉我们您在做什么。我们会尽快修复它。很抱歉给您带来不便。"

所以现在服务器声明存在404错误。我可以假设我的nginx配置没问题,而php70w-fpm工作正常。是的我使用的是PHP7。

我希望对我的错误提出一些建议,并为解决方案提供指导或指导。我不希望解决方案在银盘上交给我。

提前感谢大家的帮助。

2 个答案:

答案 0 :(得分:0)

所以在调查问题后我发现了问题。

Fatal error: Uncaught InvalidArgumentException:的初始问题是由将其更改为777时的文件夹权限引起的,这确实解决了这个问题。

我发现的下一个问题The server returned a "404 Not Found"是由数据库中缺少的数据引起的。为了在生产环境中找到这一点,我编辑了app.php行上的$kernel = new AppKernel('prod', false);以包含true而非false,从而强制显示错误报告而不是404错误。

最后,nginx配置非常完美。

答案 1 :(得分:0)

我在CentOS上遇到与<table id="table" style="width:100%"> <thead> <tr> <th>Student ID </th> <th>Student Name </th> <th>Assignment 1 </th> <th>Assignment 2 </th> <th>Assignment 3 </th> <th>Assignment 4 </th> <th>Assignment 5 </th> <th>Final Grade </th> </tr> </thead> <tbody> <tr> <!-- contenteditable="true" means you can edit it. id = "left" lets you edit part of the table differently than the rest --> <td id="left">16710169 </td> <td id="left">Shauna Goodman </td> <td id="shauna1" contenteditable="true">70 </td> <td id="shauna2" contenteditable="true">60 </td> <td id="shauna3" contenteditable="true">40 </td> <td id="shauna4" contenteditable="true">90 </td> <td id="shauna5" contenteditable="true">88 </td> <td id="shaunafinal"> </td> </tr> <tr> <td id="left">16710170 </td> <td id="left">Paul Smith </td> <td contenteditable="true">55 </td> <td contenteditable="true">- </td> <td contenteditable="true">90 </td> <td contenteditable="true">45 </td> <td contenteditable="true">80 </td> <td>- </td> </tr> <tr> <td id="left">16710171 </td> <td id="left">Marie Mckenna </td> <td contenteditable="true">50 </td> <td contenteditable="true">66 </td> <td contenteditable="true">- </td> <td contenteditable="true">70 </td> <td contenteditable="true">90 </td> <td>- </td> </tr> <tr> <td id="left">16710172 </td> <td id="left">Saoirse McGuire </td> <td contenteditable="true">45 </td> <td contenteditable="true">85 </td> <td contenteditable="true">95 </td> <td contenteditable="true">81 </td> <td contenteditable="true">59 </td> <td>- </td> </tr> <tr> <td id="left">16710173 </td> <td id="left">Nathaniel Kingston </td> <td contenteditable="true">- </td> <td contenteditable="true">70 </td> <td contenteditable="true">46 </td> <td contenteditable="true">30 </td> <td contenteditable="true">28 </td> <td>- </td> </tr> <tr> <td id="left">16710174 </td> <td id="left">Adam Jones </td> <td contenteditable="true">96 </td> <td contenteditable="true">- </td> <td contenteditable="true">90 </td> <td contenteditable="true">78 </td> <td contenteditable="true">63 </td> <td>- </td> </tr> <tr> <td id="left">16710175 </td> <td id="left">Melanie Song </td> <td contenteditable="true">96 </td> <td contenteditable="true">90 </td> <td contenteditable="true">95 </td> <td contenteditable="true">98 </td> <td contenteditable="true">97 </td> <td>- </td> </tr> <tr> <td id="left">16710176 </td> <td id="left">Sarah Cesal </td> <td contenteditable="true">70 </td> <td contenteditable="true">50 </td> <td contenteditable="true">- </td> <td contenteditable="true">25 </td> <td contenteditable="true">38 </td> <td>- </td> </tr> <tr> <td id="left">16710177 </td> <td id="left">Teresa Purcell </td> <td contenteditable="true">70 </td> <td contenteditable="true">50 </td> <td contenteditable="true">10 </td> <td contenteditable="true">25 </td> <td contenteditable="true">38 </td> <td>- </td> </tr> <tr> <td id="left">16710178 </td> <td id="left">James Hennessey </td> <td contenteditable="true">80 </td> <td contenteditable="true">50 </td> <td contenteditable="true">40 </td> <td contenteditable="true">25 </td> <td contenteditable="true">98 </td> <td>- </td> </tr> </tbody> </table> <button type="button" onclick="calculate()"> Submit </button> Symfony 4相同的问题。解决此问题的简单方法是禁用Selinux 。我希望这有助于其他人节省时间来解决这个问题。