Compiling shared PHP modules

So you want to add postgres support to PHP (or something like that), but you don’t want to re-compile the whole thing. You just want a shared module.

Its easier than I first thought. Here is how I have done it.

First create a test php page to check phpinfo() and find which version of php you are running, then download it from I’m using 5.4.14 so my example will reflect that.

Then I like to put the source in someplace like /usr/local/src/php-5.4.14

/usr/local/src/php-5.4.14 # ./configure --with-pgsql=shared,/usr/local/pgsql
/usr/local/src/php-5.4.14 # make
/usr/local/src/php-5.4.14 # cp modules/ /usr/lib64/php/extensions/

Note we only have to use the configuration line for the shared module we are compiling. We specify that we want it as a shared module, and the path (if needed). This of course assumes you already have postgres installed.

Then load that extension from php.ini by adding the following line.

[extension section]

Restart apache, and check your phpinfo() page again. You should see a section titled pgsql

Thats it =;)

This entry was posted in Apache. Bookmark the permalink.

Leave a Reply

Your email address will not be published.