[英]Symfony HTTP 500 error after several requests in production
我正在使用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
(這兩個文件都存在,並且可以通過Web服務器正常訪問)
有時,應用程序在清除緩存和/或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
之后剛被修復
同樣在vhosts.conf或httpd.conf中,驗證您是否已授予對Web目錄的訪問權限:
<Directory "/home/example/www/example.net/web/">
DirectoryIndex app.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
我前段時間在Mac OS上也有類似的東西。 Apache或PHP現在由於類似您所顯示的消息而開始崩潰
在Mac上,打開文件的數量有問題。 您可以在這里獲得一些信息https://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x- 10-7-1 。
我最終運行以下命令來修復它
sudo launchctl limit maxfiles 10000000 10000000
sudo apachectl restart
不久前我不得不面對類似的問題-有時找不到某些文件(主要是模板和/或路由文件),但它們在服務器上。 我發現這是因為我使用自己的用戶名/密碼通過Filezilla將它們上傳到服務器(因此服務器上的用戶是這些文件的所有者),但是symfony應用程序在另一個用戶下運行,並且該用戶可以如果他不是文件所有者,則不要使用文件。
我不確定您是否會遇到與我相同的問題,但是希望它能對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.