Home >Backend Development >PHP Tutorial >How to enable and disable PHP modules on Ubuntu

How to enable and disable PHP modules on Ubuntu

不言
不言Original
2019-04-09 10:50:314676browse

This article introduces to you how to enable and disable the PHP module on Ubuntu. Let’s take a look at the specific content.

How to enable and disable PHP modules on Ubuntu

All installed PHP module configuration files can be found in the /etc/php/PHP_VERSION/mods-available directory. You can see files with the .ini extension quantity. Specific PHP modules must be installed first, as they need to be enabled before use. The php public package provides the following commands to manage php modules.

phpenmod – used to enable modules in php

phpdismod – used to disable modules in php

phpquery – used to view the status of php modules

There are three types of SAPI (server API) available, the most commonly used ones are CLI, FPM, and Apache2. SAPI can be defined using the -s switch to enable/disable modules only.

Enable PHP modules

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

### Syntax
$ phpenmod MODULE_NAME

### Enable mbstring php module
$ phpenmod mbstring

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

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

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

Use -sswitch to define a SAPI to enable a specific module for a 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

It is also possible to define the php version and sapi for more specific updates.

Disable PHP modules

Any unnecessary php module can be disabled from the system using the phpdismod command. For example, disable the mbstring module for all PHP versions and all SAPIs.

$ phpdismod mbstring

To disable any module for a specific PHP version, use the command below.

$ phpdismod -v 7.2 mbstring

To disable any module for a specific SAPI on all PHP versions, use the following command.

$ phpdismod -s apache2 mbstring

This article has ended here. For more exciting content, you can pay attention to the PHP Video Tutorial column on the PHP Chinese website!

The above is the detailed content of How to enable and disable PHP modules on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn