When you run PHP from the command-line it does not necessarily use the same configuration as when run by apache.
Compare the output from php -i on the command line, with Admin -> Server -> PHP info in the Moodle interface (in particular the Loaded Configuration File value, which is the path to the php.ini file used).