PHP gd and Perl gd segfaulting
I make a lot of use of GD (through charts) in my services, which also use a mix of Perl and PHP scripts. Unfortunately PHP defaults to using an internal copy of the GD library that, when used, causes a segfault if GD is also used by mod_perl (which will use the system GD library). The segfault is the result of attemping to use two versions of the GD library at once.
The solution to this problem is to use the system GD library in PHP. I use RedHat enterprise on my servers and want to use RPMs to allow ease of keeping up to date with bug fixes. Fortunately it's pretty easy to modify the RPM source to fix this isolated problem, without having to install a compiled PHP.
Download and install the source RPM (NB make sure you install the correct version):
Change to the rpm source build directory:
Create a new file called 'php.spec.patch' containing this:
Patch the php.spec file (-l ignores whitespace):
Build the binary RPM (will take a while):
Install the new php-gd rpm:
You may want to add php-gd to the skip-list in /etc/sysconfig/rhn/up2date, otherwise if RedHat update php it'll cause your Web server to seg fault.
The solution to this problem is to use the system GD library in PHP. I use RedHat enterprise on my servers and want to use RPMs to allow ease of keeping up to date with bug fixes. Fortunately it's pretty easy to modify the RPM source to fix this isolated problem, without having to install a compiled PHP.
Download and install the source RPM (NB make sure you install the correct version):
up2date --get-source php
rpm -ivh /var/spool/up2date/php-*.src.rpm
Change to the rpm source build directory:
cd /usr/src/redhat
Create a new file called 'php.spec.patch' containing this:
--- php.spec.orig 2006-09-25 12:00:23.000000000 +0100
+++ php.spec 2006-09-25 12:00:44.000000000 +0100
@@ -433,7 +433,7 @@
--with-exec-dir=%{_bindir} \
--with-freetype-dir=%{_prefix} \
--with-png-dir=%{_prefix} \
- --with-gd=shared \
+ --with-gd=shared,/usr \
--enable-gd-native-ttf \
--without-gdbm \
--with-gettext \
Patch the php.spec file (-l ignores whitespace):
patch -l SPECS/php.spec <php.spec.patch
Build the binary RPM (will take a while):
rpmbuild -bb SPECS/php.spec
Install the new php-gd rpm:
rpm -Uvh RPMS/php-gd-*.rpm
You may want to add php-gd to the skip-list in /etc/sysconfig/rhn/up2date, otherwise if RedHat update php it'll cause your Web server to seg fault.