When I try to run a script that uses imap
in my browser, it works fine (it is loaded from a Ubuntu 14.04 server on my network with the extension installed). However, when I try to use PHP CLI on said server, it doesn't load imap
.
I wrote a simple script to check loaded extensions, using get_loaded_extensions()
, and it taught me 2 things:
- PHP CLI had 50 extensions, while running it through my web browser had 51.
- Another extension I manually declared in my
apache2/php.ini
(imagick.so
) was being loaded in both CLI and browser
Why is this happening, and how can I have all 51 extensions loaded in both CLI and browser?
Best Answer
There are separate configuration files for PHP when called via Apache and when called via the CLI.
For example, in Debian (at least), these are in
/etc/php5/apache2/php.ini
and/etc/php5/cli/php.ini
, respectively.The fact that you manually declared
imagick.so
in apache2/php.ini might not mean anything - most distributions have some other way of managing PHP modules, and can often automatically enable the extension for you, so it might have already been added.I'd suggest looking up how your linux distribution manages PHP extensions (for Debian and Ubuntu, it uses a command called
php5enmod
, which needs to be called viasudo
), or else just manually edit/etc/php5/cli/php.ini
or similar to be up to date.