Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»PHP»How to enable or disable php modules on Ubuntu

    How to enable or disable php modules on Ubuntu

    By RahulJuly 18, 20222 Mins Read

    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.

    phpdismod mbstring
    

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

    phpdismod -v 7.4 mbstring
    

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

    phpdismod -s apache2 mbstring
    

    PHP phpdismod phpenmod phpquery
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    PHP Arrays: A Beginner’s Guide

    Running Laravel Queue Worker as a Systemd Service

    How to Change PHP Session Timeout

    View 4 Comments

    4 Comments

    1. Tom on July 7, 2022 7:25 am

      Missing phpquery example here, could you please fill it

      Reply
    2. jainbishal on December 19, 2020 4:20 pm

      Thanks mate.

      Reply
    3. Alcides on September 24, 2018 1:09 pm

      Great pal!

      Reply
    4. Jassi on February 7, 2018 5:05 pm

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

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.