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

Thank you for reading this article.

Was this helpful?

2 / 1

Leave a Reply 28

Your email address will not be published. Required fields are marked *


riqisuzgkg

riqisuzgkg

Muchas gracias.

ogigixorita

ogigixorita

Thanks for sharing such a nice post, post is pleasant.

oxtiara

oxtiara

Excellent quality writing, it is rare to see a nice
blog like this one nowadays.
Thanks designed for sharing such a nice idea, post is pleasant, thats why I tried it,such a perfect approach.

onazexegiqet

onazexegiqet

Thanks designed for sharing such a nice idea, post is pleasant, thats why I tried it,such a perfect approach.

ehihatezi

ehihatezi

Information written in such a perfect approach.

oziwemu

oziwemu

I truly appreciate your efforts and I am waiting for your further write ups thanks. Where information written in such a perfect approach.

oyebusu

oyebusu

I truly appreciate your efforts.

iwevejonep

iwevejonep

I truly appreciate your efforts and I am waiting for your further write ups thanks.

caofejabizoip

caofejabizoip

Thanks for sharing your thoughts.

erexeebolose

erexeebolose

Thank you for informative website.
Where information written in such a perfect approach.

iqubohaf

iqubohaf

Thank you for informative website.

noxasawi

noxasawi

So good

ahawaeyo

ahawaeyo

Like so much!

iqiyenoux

iqiyenoux

awosunoso

Porter

Porter

hello there and thank you for your info – I’ve certainly picked up something new from right here.
I did however expertise several technical issues using this site, since
I experienced to reload the website lots of times previous to I could get it to
load correctly. I had been wondering if your web host is OK?
Not that I’m complaining, but sluggish loading instances times
will often affect your placement in google and can damage your quality score if advertising and
marketing with Adwords. Well I’m adding this
RSS to my e-mail and can look out for much more of
your respective interesting content. Ensure that
you update this again soon.

angame

angame

You’ve made some good points there. I looked on the net for more information about the issue and
found most people will go along with your views on this site.

theirps

theirps

Hi my friend! I want to say that this post is awesome, nice written and come with almost all important infos.

I would like to see more posts like this .

inames

inames

Excellent way of describing, and good post to obtain facts regarding my presentation focus, which i am going to convey in academy.

Alapati

Alapati

I really like all the points you’ve made.

MariaBA

MariaBA

There’s definitely a lot to know about this subject.

zolioptor

zolioptor

After study just a few of the weblog posts on your web site now, and I really like your way of blogging. I bookmarked it to my bookmark website list and will probably be checking again soon.

Larryamugh

Larryamugh

I recommended this website

Juanitaelape

Juanitaelape

Good one!

zortilo nrel

zortilo nrel

Good info. Lucky me I reach on your website by accident, I bookmarked it.

jucasiline

jucasiline

A big thank you for your blog.Really thank you! Really Cool.

zorimol

zorimol

Rattling superb information can be found on weblog.

Earoney

Earoney

Fantastic website. A lot of useful information here.
I’m sending it to a few pals ans additionally sharing in delicious.
And certainly, thanks to your sweat!

gralion torile

gralion torile

Wow! Thank you! I permanently needed to write on my site something like that. Can I include a fragment of your post to my site?