Tuesday, December 11, 2007

PHP5 and RHEL4

Recently I need to install PHP5 under RHEL4 (x86_64, gcc version 3.4.5) and got a trouble. Of course there was no RPMs for RHEL4 on public repositories, so I had to use SRPM. Everything seemed to be OK except one thing, when I tried to build the rpm I got error:
# rpmbuild --rebuild php-5.1.6-3.src.rpm
...
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
error: Bad exit status from /var/tmp/rpm-tmp.37368 (%build)

All my googlings gave me the only way to shoot the trouble: upgrade gcc to 4. Yes, software upgrade is always good :) but for RHEL (without a purchased repository account) takes much time and efforts. So I was looking for another way and ... got it.
The only thing which was needed by PHP5 from new gcc version (4) to build RPM was a warning flag -Wno-pointer-sign (which is not defined in gcc 3.4.5). Here we go.
# rpm -ihv php-5.1.6-3.src.rpm
# vim /usr/src/redhat/SPECS/php.spec

Find in the spec file the following line
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -Wno-pointer-sign"
Remove -Wno-pointer-sign from the line and save file.
Build RPM:
# rpmbuild -bb /usr/src/redhat/SPECS/php.spec
For me it worked OK. Just install RPMs and enjoy ;)
# rpm -Uhv /usr/src/redhat/RPMS/x86_64/php*