php5-imap on Ubuntu 14.04 is not enabled

After

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?


Solution 1:

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

Solution 2:

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)

Solution 3:

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.