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 36

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.

slotmani

slotmani

Genuinely when someone doesn’t understand after that its up to other people that they will assist, so here it
takes place.

Situs Nine

Situs Nine

I would like to thank you for the efforts you’ve put in penning this site.
I’m hoping to check out the same high-grade content from you later
on as well. In truth, your creative writing abilities has motivated me to get my own blog now.

zoritoler imol

zoritoler imol

Nice weblog right here! Additionally your web site loads up very fast! What host are you the usage of? Can I am getting your associate link on your host? I desire my web site loaded up as fast as yours lol

Slotline

Slotline

Wow, this post is nice, my younger sister is analyzing these things,
thus I am going to tell her.

warung

warung

You’re so cool! I do not think I’ve truly read through anything like
that before. So nice to find somebody with a few unique thoughts on this
subject. Seriously.. many thanks for starting this up.
This web site is something that’s needed on the internet,
someone with a little originality!

chrisbration

chrisbration

Your means of explaining the whole thing in this piece of writing is truly fastidious, every one can easily know it, Thanks
a lot.

Sempace

Sempace

It’s hard to come by experienced people for this subject, but you seem like you know what
you’re talking about! Thanks

hetipsylair

hetipsylair

I enjoy reading an article that can make men and women think.
Also, thanks for allowing me to comment!

neon4d

neon4d

Thanks a lot for sharing this with all people you actually understand what you’re talking about!
Bookmarked.

wilson golb

wilson golb

I think the admin of this web page is really working hard in favor
of his web page, as here every information is quality
based information.

supersock

supersock

Keep this going please, great job!