- How to Enable or Disable PHP Modules on Ubuntu 20.04 | 18.04
- Prerequisites
- Managing PHP Modules
- Enable PHP Modules
- Enable module for specific php version
- Disable PHP Modules
- Conclusion
- How to Enable or Disable PHP Modules on Ubuntu
- Enabling PHP Modules
- Disabling PHP Modules
- Restarting the Web Server
- Verify PHP Module Status
- Conclusion
- How to enable or disable PHP Modules on Ubuntu
- Enable PHP Modules
- Disable PHP Modules
- Debian: Как включать и выключать модули php5
- Как включить, или выключить модуль xdebug для php5 cli
- Как включить, или выключить модуль xdebug для php5 apache2
- Как работает механизм подключения/отключения модулей PHP5
How to Enable or Disable PHP Modules on Ubuntu 20.04 | 18.04
In this guide, we will be showing how you can enable or disable PHP modules on Ubuntu 20.04 LTS as well as other versions.
PHP modules are extensions that add features to the core PHP functions.
Prerequisites
In this guide, we will be making the assumption that you have already installed a supported PHP version such as PHP 7.4 or PHP 8.0 on your Ubuntu system. This short tutorial will show you how to install PHP modules on your system.
Managing PHP Modules
The php-common package provides the following commands to manage PHP modules as listed below:
- phpenmod: Used to enable modules in PHP
- phpdismod: Used to disable modules in PHP
- phpquery: Used to view status of modules of PHP
Modules can be enabled or disabled in PHP for a specific SAPI (Server API). The three common ones found on any Ubuntu system are CLI, FPM, and Apache2. You can use the -s switch to enable or disable modules in PHP for any of these.
Enable PHP Modules
To enable a specific module in PHP you need to use phpenmod command followed by module name using the following syntax.
Here is an example showing how to enable the curl module for ALL PHP versions and all SAPI.
phpenmod provides a -v switch to specify the PHP version that you intend to enable the module for with the following syntax.
$ phpenmod -v PHP_VERSION MODULE_NAME
This example shows how to enable the curl module for specific PHP versions.
Enable module for specific php version
$ phpenmod -v 7.3 curl $ phpenmod -v 7.4 curl
Moving further, this is the syntax if you need to specify the SAPI using the -s switch.
$ phpenmod -s SAPI MODULE_NAME
Now let’s enable curl for all the SAPIs individually.
$ phpenmod -s cli curl $ phpenmod -s fpm curl $ phpenmod -s apache2 curl
Disable PHP Modules
You can use phpdismod to disable any unused or unwanted PHP modules from your system. Here we will disable the curl module for all PHP versions and all SAPI.
The following command will disable the specific module for the specified version:
The following example will disable the module only for the specified SAPI
Conclusion
You should now be able to enable and disable PHP modules based on PHP version and SAPI to keep your system running optimally.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.
How to Enable or Disable PHP Modules on Ubuntu
As a developer, managing PHP modules on your Ubuntu system can be an essential part of your workflow. Modules are packages that extend the functionality of PHP, and they are a key aspect of creating dynamic and powerful web applications. This article provides a comprehensive guide on enabling and disabling PHP modules in Ubuntu, streamlining your experience and optimizing your development environment.
All the installed PHP modules configuration files are available under /etc/php//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.
- 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, and Apache2 being the most commonly used. You can define SAPI using -s switch to enable/disable module for that only.
Enabling 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
### Enable module for specific php version phpenmod -v 8.2 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
### 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.
Disabling 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.
To disable any module for a specific PHP version use the command below.
To disable any module for specific SAPI on all PHP versions, use the command below.
phpdismod -s apache2 mbstring
Restarting the Web Server
Once you have enabled or disabled a PHP module, you need to restart your web server for the changes to take effect. Depending on your web server, you can use the following commands:
sudo systemctl restart apache2
For Nginx with PHP-FPM:
sudo systemctl restart php8.x-fpm
sudo systemctl restart nginx
Replace 8.x with your PHP version (e.g., php8.2-fpm).
Verify PHP Module Status
After restarting the web server, you can verify if a PHP module is enabled or disabled by running the following command:
If the command returns the module name, it is enabled. Otherwise, the module is disabled.
Conclusion
Managing PHP modules on your Ubuntu system is a crucial part of optimizing your development environment. By following this guide, you can now easily enable and disable PHP modules on your Ubuntu system. Remember to restart your web server after making changes to ensure the new settings take effect. With this knowledge in hand, you’re now ready to enhance your PHP development experience on Ubuntu.
How to enable or disable PHP Modules on Ubuntu
All 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 php specific php modules, you need to enable it before further proceed. The php-common package provides followings commands to manage PHP modules.
- 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 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 module for all SAPI.
### Syntax phpenmod -v ### 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 ### 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 the 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.
phpdismod mbstring
To disable any module for specific PHP version use command like below.
phpdismod -v 7.4 mbstring
To disable any module for specific SAPI on all PHP versions, use command like below.
phpdismod -s apache2 mbstring
Thank you for reading this article.
Debian: Как включать и выключать модули php5
Не часто требуется, но иногда нужно включить, или отключить тот, или иной модуль PHP5. Хороший пример - выключение модуля xdebug для cli, он часто мешает при работе с composer. О том, как это сделать речь в данной статье.
Не разбирался как в предыдущих версиях php, но в php5 включение/выключение модулей очень удобно. Для этого имеются пара утилит php5enmod для включения модулей и php5dismod для выключения.
Как использовать php5enmod:
php5enmod [ -s ALL|sapi_name ] module_name [ module_name_2 ]
Как использовать php5enmod:
php5dismod [ -s ALL|sapi_name ] module_name [ module_name_2 ]
В обоих случаях можно указать sapi: apache2, если php работает как модуль apache2, или cli для консольного sapi.
Как включить, или выключить модуль xdebug для php5 cli
Почти всегда composer "ругается" на включенный модуль xdebug, вот на его примере и покажу как отключить:
Как включить, или выключить модуль xdebug для php5 apache2
Почти аналогично для модуля apache2
php5dismod -s apache2 xdebug
php5enmod -s apache2 xdebug
Как работает механизм подключения/отключения модулей PHP5
Как и у нормальных, современных продуктов типа apache2 и nginx, php5 имеет удобный механизм для влючения/выключения модулей. Весь процесс заключается в том, что утилиты php5enmod и php5dismod просто прописывают/удаляют ссылки на файлы конфигураций *.ini, расположенные в /ect/php5/mods-available в соответствующие директории (в зависимости от указанного SAPI) настроек php5: /ect/php5:
При желании это можно даже делать вручную при помощи ln -s . но зачем, когда есть php5enmod и php5dismod ?
Европейский кирпич от компании "Брикфорд" Европейский кирпич от компании "Брикфорд" в Краснодаре. krasnodar.brickford.ru