Pixelrocker
Pixelrocker

Reputation: 361

Symfony: Prod environment on webserver produces blank page

my Symfony 3 app works flawless on my local webserver. Since it´s been installed on the remote web server it produces a blank page, even the routing doesn't work. After editing web/app.php $kernel = new AppKernel('prod', false); and set it to true, the application works as expected and does not display any errors. Why does the application behave different on the local and the remote webserver. Did I miss to configure something on the remote server? Any suggestions? Thanks in advance!

Upvotes: 2

Views: 4105

Answers (5)

David Petrásek
David Petrásek

Reputation: 25

Most likely your production server is set up to not show any errors, so in order to see them you need to place this at the top of your index.php file:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED);

Upvotes: 0

Pixelrocker
Pixelrocker

Reputation: 361

Finally I have a solution to solve the problem: after the composer update I have to clear the cache of the prod environment manually by executing rm -fr var/cache/prod/*. For whatever reason does the command php bin/console cache:clear --env=prod quit working immediately after the composer update without throwing any error messages. After removing the cache files manually both the application and the cache:clear command work as expected without modifying web/app.php.

Upvotes: 4

Rikijs
Rikijs

Reputation: 788

I have plausible explanation, what might have been the problem.

I have encountered this problem earlier this year with Symfony3, while developing on Windows but deploying manually (copying project's files) to shared server with Linux.

As you say - blank page in prod environment.

  • To add to the mystery log files did not show any problems
  • So i enabled dev environment to check what is wrong
  • application worked as intended if i added app_dev.php in the URL

I overviewed all the files, more than once, but copy was done correctly.

The answer

After some time I "came across" the file: bootstrap.php.cache in var directory. It "felt suspicious".

As I had exhausted my options i just deleted it to test the result.

That solved it in my case. Site was running again. No more blank page!

I guess mixed development environment has its toll.

Upvotes: 0

Pixelrocker
Pixelrocker

Reputation: 361

Since I couldn´t find out what´s the real cause of this problem I´ve made a fresh install of my application and updated Symfony and all dependencies with composer. Although I did the same with the old installation, it does the trick this time. My guess is, something went wrong with the composer update before. Thanks again for your help! If someone has a similar problem I would appreciate if you could post how you solved the problem (or why AppKernel['prod'] = 'true' did work).

Upvotes: 0

Michał G
Michał G

Reputation: 2292

1.check permission to cache and log dirs ( need to be 777 )

2.check (paste here) error in logs/prod.log

Upvotes: 1

Related Questions