【发布时间】:2017-05-16 11:12:37
【问题描述】:
我正在使用 Symfony v3.0.9。在本地一切正常,但是当我将应用程序移至生产环境时,过了一会儿,我开始收到如下错误:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderLoadException: "Unable to find file "@FrontendBundle/Resources/config/routing.yml" in @FrontendBundle/Resources/config/routing.yml
或
request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Unable to find template "FrontendBundle::homepage/homepage.html.twig" (looked into: [...]/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form)." at [...]/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 128
或
PHP Fatal error: Cannot access property appProdProjectContainer::$parameters in [...]/var/cache/prod/appProdProjectContainer.php on line 30
(这两个文件都存在,并且可以通过网络服务器正常访问)
有时应用程序在清除缓存后可以正常工作和/或composer install 有时不能,并且在最终再次工作后需要多次尝试。源代码没有变化。
我认为这可能与应用正在处理的同时请求有关,这可能会导致缓存文件出现一些异常。
有什么想法吗?
更新 #1 - 虚拟主机配置:
<VirtualHost *:80 *:443>
ServerName example.net
ServerAlias www.example.net example.com www.example.com example.org www.example.org
DocumentRoot /home/example/www/example.net/web/
ErrorLog /home/example/www/example.net/logs/error.log
CustomLog /home/example/www/example.net/logs/access.log combined
RewriteEngine on
RewriteCond %{HTTP_HOST} example\.(org|com)$ [NC]
RewriteRule ^(.*)$ https://www.example.net$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [R=301,L]
AssignUserId example www-data
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/www.example.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.example.net/chain.pem
</VirtualHost>
更新 #2 - memory_limit 更新:
我将 PHP 中的 memory_limit 从 256MB 更新为 -1(无限制),到目前为止我还没有遇到 500 错误,除了一次。这是由于PHP Fatal error: Cannot access property appProdProjectContainer::$parameters 而在第一个rm -rf var/cache/prod 之后得到修复的
【问题讨论】:
-
这是一些奇怪的行为。你能详细说明你的虚拟主机配置+文件权限吗?
-
我不确定 Virtualhost 是否与此相关,无论哪种方式,我都使用 Virtualhost 配置更新了我的问题。此外,文件权限应该没问题:在应用程序工作和不工作之间文件权限没有变化。无论如何,这里是@FrontendBundle/Resources/config/routing.yml 的权限:-rw-rw-r-- 1 example example 2103 Dec 26 23:35 FrontendBundle/Resources/config/routing.yml
-
好像是cmets @Florent这样的文件权限问题
-
您是否有区分大小写的问题? (开发上的 mac,产品上的 linux 或类似的东西?)
-
不,据说丢失的文件存在于文件系统中。这就是为什么我认为这可能只是一个并发问题。