0

Previously, my site runs on PHP 7.1 on Ubuntu 14.04 LTS and upgraded to Ubuntu 16.04. After upgrade, I can still access my site.

Then I install and switch to PHP 7.2 (I didn't remove PHP 7.1, only disable it). When accessing, it shows laravel error about database connection error. Then I enable mysql and pdo_mysql in /etc/php/7.2/cli/php.ini. After that, my site only return 500 internal server error.

I checked /var/log/apache2/error.log and it says

[Tue Dec 17 11:12:36.773684 2019] [php7:error] [pid 27730] [client xxx.xxx.xxx.xxx:y] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 31

The memory_limit in /etc/php/7.2/cli/php.ini is already -1 from start.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

0

You probably have multiple configuration files for the different PHP interfaces. You have edited the cli configuration.

To check, which configuration you are using with the apache2 sapi, you can create a test.php in your document root like below

test.php

<?php
phpinfo();

Then open test.php in your web browser. There is a row labeled „loaded configuration file“

Edit the configuration, I don’t recommend to set the memory limit to -1 (not limited by php) for websites. Choose a value that suits your requirements. It should be a multiple of 128MB. Restart Apache after changing the value. Remove the test.php when you’re done.

Two more things on Ubuntu and Apache:

Choose system default php version like so

update-alternatives --set php /usr/bin/php7.2

Choose Apache php version like so

a2enmod php7.2
systemctl restart apache2
Michel Feldheim
  • 17,625
  • 5
  • 60
  • 77