Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active March 13, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riceissa/0cd89c6beaedfc1934a6d889d353af75 to your computer and use it in GitHub Desktop.
Save riceissa/0cd89c6beaedfc1934a6d889d353af75 to your computer and use it in GitHub Desktop.
php-fpm/apache can't find extensions after ubuntu/debian upgrade

I've encountered this bug twice now, after upgrading ubuntu in january 2018 (probably to ubuntu 17.10) and when upgrading debian from stretch to buster.

here's what the bug is like. running things like php -m | grep mysqli shows that the commandline version of php can find extensions, but doing print_r(get_loaded_extensions()); in a php file and then viewing it in the browser shows that the extensions are not loaded in php-fpm/apache.

Here are some things that are suggested on stack overflow and similar sites, but they don't work:

  • installing and reinstalling the extensions using the package manager, like apt install php-mbstring.
  • editing config files (the php-fpm/apache version of php.ini which is located at /etc/php/7.3/fpm/php.ini, not the commandline version of php.ini which is located at /etc/php/7.3/cli/php.ini) and then restarting nginx/apache/php.

i finally just purged (not just removed) nginx/apache/php and that works. here's the version for nginx:

apt purge nginx*  # this will remove all nginx config files! make backups before you run this!
apt purge php*
apt install nginx php7.3 php7.3-fpm php7.3-mysql
apt install php-mbstring php-xml

i'm actually not sure if purging nginx/apache is necessary. you might only need to purge php.

another weird thing: the old version of php (7.0 in my most recent case) is not removed from the system after the upgrade. at first, php-fpm continues to use the old version of php because that's what my nginx config file says. so i manually removed php7.0 and then changed the nginx config files to use php7.3. that's probably a good thing to do, but it doesn't fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment