3

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?

6

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 via sudo), or else just manually edit /etc/php5/cli/php.ini or similar to be up to date.

2
  • Awesome, I'll take a look at that Jan 1 '16 at 23:25
  • That fixed it, thank you so much! I never noticed that there was a folder for cli in /etc/php5/ Jan 2 '16 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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