apt-get install php5-imap

I still have to manually do

php5enmod imap

which seems odd and inconsistent. Is there any particular reason for this?


Yes this is a little odd. The steps involved to install this (for future users who have problems are as follows)

sudo apt-get install php5-imap
sudo php5enmod imap
sudo service apache2 restart
  • root@4385-2889-2142:~# sudo php5enmod imap sudo: php5enmod: command not found – Kaspar L. Palgi Dec 7 '15 at 22:20
  • 3
    @KasparL.Palgi, when you are logged in as root you don't need sudo. It just makes no sense. – Dekel Dec 8 '15 at 12:24

I came upon the same problem but now a few years have passed. Mark Aronis answer is correct, but the software changed. Use that instead:

sudo apt-get install php7.0-imap 
sudo phpenmod imap

(Sry, I can't leave comments yet)


To answer the question if there's a particular reason for it, yes there is ;) You can interface Apache with PHP in several ways (mod_php, cgi, fcgi, scgi, php-fpm, cli ...). And you can use multiple of those server APIs (SAPIs) on the same machine in parallel and decide by site / vhost which to use (considering issues like performance, security or compatibility).

If PHP modules would get activated just by installation, they would get activated across all available SAPIs. But what if you need to differentiate? Maybe you want a module available for php-fpm (because you set up sufficient security checks there), but not from the command line cli interface? Or you want to configure the module in different ways for different SAPIs. Or you just need to temporarily de-activate a module while somebody's running an attack on your server, and don't want to loose the configuration you worked a day to setup and finetune.

To do those things, there's a structure of directories and config files under /etc/php5. And quite similar to that what a2ensite / a2dissite do for Apache vhosts and what a2enmod / a2dismod do for Apache modules, you can manage PHP modules with phpenmod / php5dismod.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.