July 17, 2017

Managing PHP Modules

We see how PHP is configured and how to manage PHP's modules.

^ Ad space to help offset hosting costs :D

Available modules, some that come with PHP, and some we installed ourselves, are available in /etc/php/<VERSION>/mods-avaiable.

These are set per SAPI - cli, fpm, apache2 being the most common.

So, for web requests, we can check out the fpm section, and specifically the conf.d directory:

ls -lah /etc/php/7.1/conf.d

We see a bunch of symlinks to the mods-available directory.

Enable / Disable

To enable or disable a module for a SAPI, we can create or destroy a symlink in the conf.d directory for that SAPI. We'll need to restart php-fpm if we change it, but CLI-run PHP is affected immediately (since each call to php on the command line is starting a new process).

Note that this means your cron tasks / queue workers may have a different php.ini and set of modules than your web-run php.

We can also use the simpler phpenmod and phpdismod commands. Use the -s flag to define a specific SAPI if you don't want all of them affected.

# Disable xdebug for php-fpm
sudo phpdismod -s fpm xdebug
sudo service php7.1-fpm reload

All Topics