Usually changing any configuration of Apache or PHP configuration on the cPanel machine involves the use of EasyApache. This is a nice install script, but it rebuilds both Apache and PHP from scratch, which seems a bit extensive for a small reconfiguration. Also, it does not offer too many PHP extensions – so it may not be the best way.
However, there is another way to install a PHP extension on a cPanel server – PECL. We can use it to install any extension available through PECL channels, then just add it to the php configuration through cPanel so it does not wipe it out next time the EasyApache needs to run.
It is even advised by cPanel to use this way for PDO extension in case you need more PDO drivers than the standard SQLite and MySQL ones.
Heres how to do it :
1. Install an extension through PECL on command line:
pecl install PDO
pecl install PDO_MYSQL
We are looking for something like this on the end:
Build process completed successfully
Installing ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so’
install ok: channel://pecl.php.net/PDO_MYSQL-1.0.2
Extension PDO_MYSQL enabled in php.ini
Actually, the last line is incorrect, the extension is installed in an extensions directory – but to be enabled after the above.
2. Enable the extension in PHP:
Go to the WHM and find “PHP Configuration Editor” in the left-hand side menu. Enable “Advanced Mode” on the page it shows and search for “extension” directive under “Core” section.
Make sure (you will most likely have to add it manually) that the value (most right-hand side column) contains your module, for example:
“pdo.so, pdo_mysql.so, timezonedb.so”
The list may be longer, as it should contain all extensions that have been enabled this way.
Hit “save” on the bottom of the page and you’re done!
3. Restart Apache to apply the changes. It can be done through WHM or on command line.