简体   繁体   English

Symfony 5 在 prod 但不是 dev 的问题

[英]Problem with Symfony 5 in prod but not dev

I have a problem with my project in symfony 5.4 (recently update from 4.4) I deploy my project on the prod server (on a subdomain) and he don't work in prod environnement, but work in dev.我在 symfony 5.4(最近从 4.4 更新)中的项目有问题I already:我已经:
_ fix permissions for /var folder _ 修复 /var 文件夹的权限
_ set up vhosts (i'm on plesk so i put directives in vhost.conf, in my subdomain) _ 设置虚拟主机(我在 plesk 上,所以我将指令放在 vhost.conf 中,在我的子域中)
_ install and update composer _ 安装和更新作曲家

The problem is that there is a lot of missing image (it's ok they are on prod), when i run the project in dev, missing image return a 404 error, but when i turn symfony on prod, missing image return a 500 error, and then the all site is on error 500 untill i clear symfony cache.问题是有很多丢失的图像(没关系他们在产品上),当我在开发中运行项目时,丢失的图像返回 404 错误,但是当我在产品上打开 symfony 时,丢失的图像返回 500 错误,然后所有站点都出现错误 500,直到我清除 symfony 缓存。

I have the previous verison (the 4.4 one), who run in the principal domain, and i dont have this problem.我有以前的版本(4.4 版本),在主域中运行,我没有这个问题。 I deploy the exact same project (the new one in 5.4), in an others test server, and he works in dev and prod (no error 500 on image).我在其他测试服务器上部署了完全相同的项目(5.4 中的新项目),他在 dev 和 prod 工作(图像上没有错误 500)。

I think it's a server problem, but i passed 4 days on this, i tried a lot of thing, and i'm still stuck:)我认为这是一个服务器问题,但我已经过了 4 天,我尝试了很多东西,但我仍然卡住了:)

Do you use Webpack?你用的是 Webpack 吗? Have you tried deleting the prod folder in var/cache?您是否尝试过删除 var/cache 中的 prod 文件夹? Otherwise I had made a short video showing how to deploy symfony, you can try to follow the procedure (video in French)否则我制作了一个简短的视频来展示如何部署 symfony,您可以尝试按照程序进行操作(法语视频)

First, thank you for trying to help me, i appreciate that.首先,感谢您试图帮助我,我很感激。 So.所以。

For removing the error with the image (error 500 instead 404), it appears that the problem was coming from my error templates 'bundles/TwigBundles/error.html.twig', i removed all the code and try just a simple tag, clear the cache and then the missing images trhow a 404 error.为了删除图像错误(错误 500 而不是 404),问题似乎来自我的错误模板“bundles/TwigBundles/error.html.twig”,我删除了所有代码并尝试了一个简单的标签,清除缓存,然后是丢失的图像 trhow 404 错误。
I also reinstall composer require symfony/twig-pack我还重新安装 composer 需要 symfony/twig-pack
This helped me: https://stackoverflow.com/a/13741553/20040268这对我有帮助: https://stackoverflow.com/a/13741553/20040268
So the site was running fast this time, but as soon i changed page, error 500 again...at least it was fast ^^所以这次网站跑得很快,但是我一换页,又报错500……至少它很快^^

So i keep digging, and like @user1915746 said, i started searching with php and the error code i send: mod_fcgid: error reading data from FastCGI server.所以我继续挖掘,就像@user1915746 所说,我开始使用 php 和我发送的错误代码进行搜索:mod_fcgid:从 FastCGI 服务器读取数据时出错。

I tried a lot of thing for removing this error like: https://stackoverflow.com/a/12192622/20040268我尝试了很多方法来消除此错误,例如: https://stackoverflow.com/a/12192622/20040268
But still not resolved my problem.但仍然没有解决我的问题。 Finally i decided to change the all php ^^ I was in 7.4.30, i pass in php 8.0.20 and...voila...no more error 500...最后我决定更改所有 php ^^ 我在 7.4.30,我通过了 php 8.0.20 和...瞧...没有更多的错误 500...

If you guys have the same thing, and tried all i tried, change php version or if you can't try to see if you don't have missing package (like php-cgi).如果你们有同样的事情,并且尝试了我尝试的所有方法,请更改 php 版本,或者如果您无法尝试查看是否缺少 package(如 php-cgi)。

Thank you again for your time!再次感谢您的宝贵时间!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM