It might be that PHP on apache uses a different php.ini
files than PHP on CLI.
Find out for CLI by running
$ php --ini
The php.ini for apache can be seen in phpinfo().
If they are different, you need to add the extension loading directive to the CLI one, too.
Also make sure to restart apache after modifying the php.ini for mod_php.