Playing with Pecl
I decided to try writing a PHP extension. My C is pretty rusty, this will help me get back into shape. Plus, it would be nice to get my work out there in a place like Pecl. I thought it would be nice to keep track of what I am doing in my blog.
First things first - check on how other people are doing it. I found some nice tutorials on the pecl site. Almost al of them reference php4, but I found out writing a php extension in php5 is exactly the same.
There was just one hitch. All of the tutorials assume you are downloading php and compiling it by hand. Because I have been running Gentoo, I’ve just been using Portage to install everything. I spent a bit of time trying to figure out if I could still use the tutorials with Portage, but being unfamiliar with the portage engine, it was a difficult task. I’ll probably come back to it once I have my extension working, but for now, I decided to go back to the manual compile method.
That brings me to today. I downloaded php, compiled it with the same flags Portage uses, but it wouldn’t install. I see this message:
washingmachine php-5.2.4 # make install
Installing PHP SAPI module: apache2handler
/usr/lib/apache2/build/instdso.sh SH_LIBTOOL=’/usr/share/apr-0/build/libtool’ libphp5.la /usr/lib/apache2/modules
/usr/share/apr-0/build/libtool –mode=install cp libphp5.la /usr/lib/apache2/modules/
cp .libs/libphp5.so /usr/lib/apache2/modules/libphp5.so
cp .libs/libphp5.lai /usr/lib/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool –finish /root/php-5.2.4/libs’
chmod 755 /usr/lib/apache2/modules/libphp5.so
apxs:Error: Config file /etc/apache2/apache2.conf not found.
make: *** [install-sapi] Error 1
Simple enough to fix - Gentoo names the apache config file httpd.conf instead of apache2.conf. Not sure how to set that during the install, so I just create a link file:
ln /etc/apache2/httpd.conf /etc/apache2/apache2.conf
And we’re up and running. Now time to get to the dirty work.