• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to enable or disable PHP Modules on Ubuntu

Written by Rahul, Updated on May 8, 2020

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.

  • 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 <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 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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

3 Comments

  1. Avatar jainbishal Reply
    December 19, 2020 at 4:20 pm

    Thanks mate.

  2. Avatar Alcides Reply
    September 24, 2018 at 1:09 pm

    Great pal!

  3. Avatar Jassi Reply
    February 7, 2018 at 5:05 pm

    Thanks for writing useful article… Finally I found an article to understand about php module management…

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy