Compiling shared PHP modules

by @jehiah on 2005-12-26 06:08UTC
Filed under: All , PHP

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 php.net. I’m using 4.3.8 so my example will reflect that.

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

/usr/local/src/php-4.3.8 # ./configure --with-pgsql=shared,/usr/local/pgsql
/usr/local/src/php-4.3.8 # make
/usr/local/src/php-4.3.8 # cp modules/pgsql.so /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]
extension=pgsql.so

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

Thats it =)

Subscribe via RSS ı Email
© 2023 - Jehiah Czebotar