doufu6196 2016-07-19 07:58
浏览 39

Symfony3出口到生产

I have a server running on apache2 with some virtual hosts and I want to deploy a Symfony3 application on it. However, I cannot deploy it correctly to the production environment, it works perfectly on development environment. Whenever I do execute

sudo composer install --no-dev --optimize-autoloader 

I get the error: PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /my/path/app/AppKernel.php on line 25 Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command: PHP Fatal error:  Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle'not found in /my/path/app/AppKernel.php on line 25.

After getting this error I went to read the documentation again and it said that I need to export this the Symfony environment to production. So I did that:

export SYMFONY_ENV=prod

After that I executed the composer install command again but, same results.

Some people on Stackoverflow (and other sources) said that I need to clear my cache by executing

sudo bin/console cache:clear --env=prod

So I did that but same results. Anyone any idea?

Other sulutions tried: Actually it works great whenever I execute the command this way:

sudo SYMFONY_ENV=prod composer install --no-dev --optimize-autoloader 

However, whenever everything was installed correctly, I went to try to visit the URL and I got a 500. So I went to the Apache2 logs to check if something was wrong and I saw the same RuntimeException again.

EDIT

So I've also followed the instructions of this link but unfortunately, same results. I also checked if I've got everything installed correctly such as ACL and I did.

I also did an getfacl /my/path/var/cache and it showed the correct information based on this link.

EDIT #2

I've also already run php bin/symfony_requirements and it showed me that 'My system is ready to run Symfony Projects', even after php bin/console cache:clear --env=prod --no-debug

  • 写回答

1条回答 默认 最新

  • dqd54099 2016-07-19 15:35
    关注

    I'm not certain what the problem could be, but since this is a new deploy, make sure you have setup the correct install requirements. For apache, normally the user is apache and group is apache.

    In a production environment an easy way to set the correct owner:group is the following command:

    $sudo chown -R apache:apache /var/www/html/test.karljohnchow.com/
    

    Also, this link: http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup

    Describes how to setup the ACL permissions on Linux (and MacOS), and the var directory needs special permissions.

    Make sure you check those things and see if that helps.

    Edit #2. I saw your comment. One of those links is for Symfony2 and it's old. I don't suggest using references that are old. They may refer to Symfony2 which is different than Symfony3.

    Take a look at this link: http://symfony.com/doc/current/cookbook/deployment/tools.html

    Have you run the php bin/symfony_requirements command yet? This is important that this passes. It'll point out problems. Also the command to clear (and warm-up) the cache is:

    $ php bin/console cache:clear --env=prod --no-debug
    

    That's different from what you show above.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!