Search code examples
phpsymfonyapc

Can't load the webpage in symfony production


When I run the app_dev.php file, the webpage works fine. But it shows blank page when I run the app.php. I tried to run this command php app/console cache:clear --env=prod --no-debug. But it produces error like this

PHP Fatal error:  Call to undefined function Doctrine\Common\Cache\apc_fetch() in /home/david/Documents/web_mikro/mikroweb/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php on line 40

I don't have any idea about this. Also I try to create one file to clear apc in web/ folder. This is the temporary file

<?php
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');

And I delete this file. But nothing works. It keeps show the blank page in app.php. Also I have updated this

sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart

and this

apt-get install apache2
apt-get install libapache2-mod-php5
apt-get install php-pear
apt-get install php5-dev
apt-get install make
apt-get install apache2-prefork-dev
pecl install apc

But the result is same.


Solution

  • You should try to add at the beginning of your app.php file:

    phpinfo();exit;
    

    And then look that apc is correctly enabled

    Also look at your PHP errors (/var/log/...)

    And eventually check that your config_prod configuration has apc enabled, something like:

    framework:
        validation:
            cache: apc
    
    doctrine:
        orm:
            metadata_cache_driver: apc
            result_cache_driver: apc
            query_cache_driver: apc