dardar.moh
dardar.moh

Reputation: 6725

Symfony2 Errors are displayed in Production mod

I moved my application in production mode in symfony 2 with this cmd Line

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

And In my "web/app.php" file

$kernel = new AppKernel('prod', false);

I changed false value to true

$kernel = new AppKernel('prod', true);

But My application still give me pages error like DEV mod ; For example whene i try to access a wrong link a get this page error

enter image description here

Normaly the page error should be like this enter image description here

Upvotes: 1

Views: 143

Answers (2)

chalasr
chalasr

Reputation: 13167

First, verify if the .htaccess is present in the web directory of your app.
Otherwise, take it from here and create it.

Open it and check that URLs are redirected to /app.php/ .
If you see a line containing app_dev.php, change it to app.php.

For example, if you see the following line:

RedirectMatch 302 ^/$ /app_dev.php/

Change it to :

RedirectMatch 302 ^/$ /app.php/

Then, verify your web/app.php looks like default .

Also, the line you given should be :

new AppKernel('prod', false')

And last, in the vhost of your prod environment, verify you doesn't specify any index like app_dev.php.
The default .htaccess do it for you.

The vhost can be like follows:

<VirtualHost *:80>
  ServerName your.domain
  DocumentRoot /var/www/path/to/project/web
  <Directory "/var/www/path/to/project/web">
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

Hope your problem come from one of this common errors.

Upvotes: 2

Carlos Delgado
Carlos Delgado

Reputation: 3065

  • Check that your virtual host (or the .htaccess) is pointing to the app.php file
  • Clear the cache manually deleting the content of the cache folder

    Note that the second parameter of the kernel needs to be false, otherwise the message errors will display anyway.

    $kernel = new AppKernel('prod',false);

Upvotes: 1

Related Questions