LinuxCommandLibrary

phpenmod

Enable or disable PHP modules

TLDR

Enable the JSON extension for every SAPI of every PHP version

$ sudo phpenmod [json]
copy

Enable the JSON extension for PHP 7.3 with the cli SAPI
$ sudo phpenmod -v [7.3] -s [cli] [json]
copy

SYNOPSIS

phpenmod module_name

PARAMETERS

module_name
    The name of the PHP module to enable or disable.

DESCRIPTION

The phpenmod command is a utility used to easily enable or disable PHP modules.
It simplifies the process of managing PHP extensions without directly editing PHP configuration files (php.ini).
This helps to keep your PHP environment consistent and avoid potential errors from manual editing.
The command works by creating or deleting symbolic links in the appropriate modules-available and modules-enabled directories.
It typically resides under the `/usr/sbin` directory.
This command is part of the Debian PHP packaging system and simplifies PHP module management.
By using phpenmod, you can ensure that your modules are correctly enabled or disabled, avoiding common configuration problems.
Note: this tool primarily works on Debian-based systems.

CAVEATS

  • phpenmod is specific to Debian-based systems (e.g., Ubuntu, Debian).
  • It relies on the Debian PHP packaging system and directory structure.
  • Requires root privileges (sudo).

DIRECTORY STRUCTURE

phpenmod operates using a specific directory structure:

  • /etc/php/[php_version]/mods-available/: Contains configuration files (.ini) for all available PHP modules.
  • /etc/php/[php_version]/cli/conf.d/ or /etc/php/[php_version]/apache2/conf.d/: Contains symbolic links to the modules enabled for CLI or Apache2 respectively.

HISTORY

phpenmod was created as part of the Debian PHP packaging system to address the complexities of managing PHP modules.
Before phpenmod, enabling and disabling modules required manual editing of php.ini files, which was prone to errors.
It's tightly integrated with the Debian's php-common package.

SEE ALSO

php(1), phpdismod(1), a2enmod(1), a2dismod(1)

Copied to clipboard