How to enable PHP extensions?

All the installed PHP modules configuration files are available under /etc/php/{php_version}/mods-available directory. You can see the number of files with extension .ini. You must have installed specific PHP modules, you need to enable before using this tutorial. The php-common package provides followings commands to manage PHP modules.

Advertisement

  • phpenmod – Used to enable modules in PHP
  • phpdismod – Used to disable modules in PHP
  • phpquery – Used to view status of modules of PHP

There are 3 types of SAPI (Server API) available – CLI, FPM, Apache2 being the most commonly used. You can define SAPI using -s switch to enable/disable module for that only.

Enable PHP Modules

Use phpenmod command followed by module name to enable specific PHP module on your system. In the below example, the first command is an example and the second command will enable mbstring module for all installed PHP versions and all SAPI.

### Syntax
phpenmod MODULE_NAME

### Enable mbstring php module
phpenmod mbstring

You can also define the PHP version using -v switch to enable specific modules. Using this you will enable the module for all SAPI.

### Syntax
phpenmod -v <PHP VERSION> <MODULE NAME>

### Enable module for specific php version
phpenmod -v 5.6 mbstring
phpenmod -v 7.4 mbstring

Use -s switch to define the SAPI to enable specific modules for specific SAPI for all PHP versions.

### Syntax
phpenmod -s <SAPI> <MODULE NAME>

### Enable module for specific SAPI
phpenmod -s cli mbstring
phpenmod -s fpm mbstring
phpenmod -s apache2 mbstring

You can also define both the PHP version and SAPI for a more specific update.

Disable PHP Modules

You can also disable any un-necessary PHP modules from your system using phpdismod command. For example, disable mbstring module for ALL PHP versions and all SAPI.

Plesk gives you the ability to enable or disable specific PHP extensions, and also to manually configure a wide range of PHP settings. These settings can be configured for every PHP version independently of all others (for example, you can set up a list of enabled extensions for PHP 5.3 that is entirely different to that of PHP 5.4) and are applied to every PHP handler type (for example, if you enable the xdebug extension for PHP 5.3, it will be enabled for all domains using PHP 5.3, whether they use CGI, FastCGI, or PHP-FPM handler).

To change the PHP settings for an individual PHP version, go to Tools & Settings > PHP Settings and click the name of any of the PHP version + handler type combinations whose PHP version matches that whose settings you want to change. For example, if you want to change settings for PHP 5.3, you can click either 5.3.3 Apache module or 5.3.3 FastCGI application. You can manage the following PHP settings here:

  • Enable or disable PHP extensions from a predefined list.
  • Configure the desired PHP settings by editing the php.ini file.

Any changes you make will be in effect for all websites using that PHP version. Note that customers who have the permission to manage PHP settings are able to configure certain PHP settings for their domains and subdomains. Settings they configure on the domain level will override server-wide settings.

  1. ISPmanager 5 Lite Documentation
  2. PHP
  3. Install a PHP extension manually

Install a PHP extension manually

Native PHP version


Execute the command below to install an extension for the native PHP version:

CentOS

yum install <package name>

BASH

Debian

apt install <package name>

BASH

Alternative PHP version


You can install an extension for the alternative PHP version:

  • using the package manager Pecl;
  • from the source code.

Install an extension using the package manager Pecl

Let's install memcache as an example:

  1. Install the packages:

    CentOS

    yum install autoconf gcc zlib-devel

    BASH

    Debian

    apt install autoconf gcc zlib1g-dev

    BASH

    Note.

    Additional packages may be required when you install other extensions.

  2. Install the extension:

    /opt/<PHP version directory>/bin/pecl install memcache

    BASH

  3. Connect the extension for a required PHP version:

    echo extension=<extension library name> >> /opt/<PHP version directory>/etc/php.d/<extension name>.ini

    BASH

    For example:

    echo extension=memcache.so >> /opt/<PHP version directory>/etc/php.d/memcache.ini

    BASH

Install from the source code

Let's install env as an example::

  1. Download and extract the archive with the extension source code:

    cd /tmp
    wget -O env.tar.gz http://pecl.php.net/get/env
    tar xzvf env.tar.gz
    cd env-0.2.1/

    BASH

  2. Run the configuration and setup process:

    /opt/<version directory PHP>/bin/phpize
    ./configure --with-php-config=/opt/<PHP version directory>/bin/php-config && make && make install

    BASH

  3. Enable the extension globally for the required PHP version:

    echo 'extension=env.so' > /opt/<PHP version directory>/etc/php.d/20-env.ini

    BASH

Note.

The extension setup process may require additional packages that are not described in this article.

×

How do I enable PHP extensions in Windows?

Step 1: Click on the Config button then select the php. ini file for your PHP installation, and open it in a text editor. Step 2: Locate the line that specifies the location of the “extension = ” line. Step 3: Look for the extension you want to install and remove the semicolon preceding that line.

How to add PHP extensions?

Install an extension using the package manager Pecl.
Install the packages: CentOS. ... .
Install the extension: /opt/<PHP version directory>/bin/pecl install memcache. ... .
Connect the extension for a required PHP version: echo extension=<extension library name> >> /opt/<PHP version directory>/etc/php.d/<extension name>.ini..

How do I show PHP extensions?

If your server only has a single PHP version installed, you can run this PHP command anywhere, and it will give you the same list of modules. The general command we will be using is php -m. This command will give you the full list of installed PHP modules/extensions.

How to enable PHP extension Ubuntu?

Follow these steps to install it:.
Install the following package: sudo apt-get update sudo apt-get install -y autoconf..
Enable the module in the /opt/bitnami/php/etc/php.ini file by adding this line to the end: extension=redis.so..
Check that the module was correctly installed with the following command: php -m | grep redis..