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 mbstringYou 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 mbstringUse -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 mbstringYou 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.
- ISPmanager 5 Lite Documentation
- PHP
- Install a PHP extension manually
Native PHP version
Execute the command below to install an extension for the native PHP version:
CentOS
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:
Install the packages:
CentOS
yum install autoconf gcc zlib-develBASH
Debian
apt install autoconf gcc zlib1g-devBASH
Note.
Additional packages may be required when you install other extensions.
Install the extension:
/opt/<PHP version directory>/bin/pecl install memcache
BASH
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::
Download and extract the archive with the extension source code:
cd /tmp wget -O env.tar.gz //pecl.php.net/get/env tar xzvf env.tar.gz cd env-0.2.1/
BASH
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
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.
×