I just recently had to do this so I thought I might as well share. There are a few threads already with some info, but it's not entirely complete in my opinion.
Let's get started.
1) First off, issue this command to check your pear/pecl config:
This will show you your config. Now if your /tmp is mounted noexec, skip the following and jump to step 2) now.Code:
My /tmp is mounted noexec and instead of messing with it, I just changed the config to a local writable directory.
Your config-show should have:
Take note of the /tmp paths.Code:
PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR Installer download download_dir /tmp/pear/cache PEAR Installer temp directory temp_dir /tmp/pear/temp
Type and execute:
Feel free to change the path to your own liking.Code:
pear config-set cache_dir /root/tmp/pear/cache pear config-set download_dir /root/tmp/pear/cache pear config-set temp_dir /root/tmp/pear/temp
2) Now we will install pdo and pdo_mysql extensions.
Type and execute:
Now check your extensions directory to make sure they were installed. For my purposes they were in /usr/local/lib/php/extensions/no-debug-non-zts-20060613.Code:
pecl install pdo pecl install pdo_mysql
You should see pdo.so and pdo_mysql.so there.
3) Next you will need to re-compile PHP5. Before doing so, edit the configure file and add the following:
Next recompile PHP with your method of choice.Code:
--enable-pdo=shared \ --with-pdo-mysql=shared \ --with-sqlite=shared \ --with-pdo-sqlite=shared \
4) Last step is to edit your /usr/local/lib/php.ini file.
Change your extension_dir to:
Change this path if yours is different.Code:
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613
Scroll down and add the following extensions:
Exit and save your php.ini.Code:
5) Restart httpd and open up a phpinfo.php file. You should now see pdo/pdo_mysql entries.
A) If you are receiving the following warning/error:
Try restarting mysqld first.Code:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo_mysql.so' in Unknown on line 0
Installing PDO headers: /usr/local/include/php/ext/pdo/ Increasing memory limit to 32M... PHP 5.3.2 Installed. Rewriting all users httpd.conf files, please wait... In debug mode Debug set to level 10 root priv set: uid:0 gid:0 euid:0 egid:0 pidfile written staring queue done queue Restarting apache. Stopping httpd: [ OK ] Starting httpd:
bash-3.2# /usr/local/bin/php PHP Warning: PHP Startup: PDO: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in Unknown on line 0 PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in Unknown on line 0 PHP Warning: PHP Startup: apc: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_stmt_instantiate': /home/tmp/PDO-1.0.3/pdo_dbh.c:410: error: 'zval' has no member named 'refcount' /home/tmp/PDO-1.0.3/pdo_dbh.c:411: error: 'zval' has no member named 'is_ref' /home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_stmt_construct': /home/tmp/PDO-1.0.3/pdo_dbh.c:435: error: 'zend_fcall_info' has no member named 'object_pp' /home/tmp/PDO-1.0.3/pdo_dbh.c:458: error: 'zend_fcall_info_cache' has no member named 'object_pp' /home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'zim_PDO_setAttribute': /home/tmp/PDO-1.0.3/pdo_dbh.c:752: error: 'zval' has no member named 'refcount' /home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'zim_PDO_getAttribute': /home/tmp/PDO-1.0.3/pdo_dbh.c:818: error: 'zval' has no member named 'refcount' /home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_hash_methods': /home/tmp/PDO-1.0.3/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type /home/tmp/PDO-1.0.3/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type make: *** [pdo_dbh.lo] Error 1