CentOS: Install PHP 5.2 with t1lib support

The first step is to vanilla install PHP 5.2 (to handle any dependency issues) and then recompile it with the t1lib option. So enable the testing repo of CentOS 5. Change to root user first, then create the repo:

su -
vi /etc/yum.repos.d/CentOS-Testing.repo

Enter insert mode (hit i) and paste the following into the new file:

# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*

Then update PHP and restart Apache (yum will double-check you want to go ahead):

yum update php*
service httpd restart

PHP is now updated, but the t1lib is not installed or compiled into PHP. So let’s download and install it (you’ll need make and gcc installed):

cd ~admin/software
wget ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
tar zxfv t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure
make && make install

If it exits with a latex error, install latex:

yum -y install tetex-latex

Installing t1lib can also be accomplished if you have the rpmforge repo installed (see previous post step 6) with: yum --enablerepo=rpmforge install t1lib
If you upgrade your software in the future and get an error about libt1.so.5()(64bit) then install t1lib again using this method and then service httpd restart

Then run the make commands again. T1lib is now installed. Next step is to recompile PHP. Firstly, set up a build environment (still as root) and install some software that we’ll need to compile:

mkdir -p /usr/src/redhat/{SRPMS,RPMS,SPECS,BUILD,SOURCES}
chmod 777 /usr/src/redhat/{SRPMS,RPMS,SPECS,BUILD,SOURCES}
yum -y install rpm-build re2c bison flex

Now, we need to lose our root privileges to compile the software, so we need to run exit or logout to drop back to the admin user (make sure this is the right version of PHP you have just installed, use rpm -q php to check).

exit
cd ~admin/software
wget http://dev.centos.org/centos/5/testing/SRPMS/php-5.2.10-1.el5.centos.src.rpm
rpm --install php-5.2.10-1.el5.centos.src.rpm
vi /usr/src/redhat/SPECS/php.spec

Technically, we should edit the release line to reflect the changes we are making, but that creates dependency issues, so we’ll ignore that and edit the configure lines. Scroll to where is says %configure with various includes after the line. Remove the line that says --disable-rpath \ which will stop the compile working (this is PHP bug #48172) and add at the end: --with-t1lib \

Exit insert mode, save and exit (hit Esc, then ZZ). Now rebuild the RPM files:

rpmbuild -bb /usr/src/redhat/SPECS/php.spec

It’s highly likely that you will now get a list of failed dependencies. All of them need to be installed. The following is my list – yours may be different. Su to the root user and install them, then logout back to the admin user after this command:

su -
yum -y --skip-broken install bzip2-devel curl-devel db4-devel expat-devel gmp-devel aspell-devel httpd-devel libjpeg-devel libpng-devel pam-devel libstdc++-devel sqlite-devel pcre-devel readline-devel libtool gcc-c++ libc-client-devel cyrus-sasl-devel openldap-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel ncurses-devel gd-devel freetype-devel
exit

Then run the rpmbuild command again. If you get a GD error after the T1_StrError line, try running this command as root:

su -
ldconfig /usr/local/lib
exit

Run the rpmbuild command again (as non-root). When it finishes (will take a while), install the resultant RPM files as root user:

su -
cd /usr/src/redhat/RPMS/x86_64/
rpm -Uhv --nodeps --force *.rpm
service httpd restart
exit

Your path to the RPMs may be different depending on your architecture.

Tagged , , , . Bookmark the permalink.

2 Responses to CentOS: Install PHP 5.2 with t1lib support

  1. Pingback: How to activate t1lib? – Stars Blog

  2. John says:

    Hi,

    I thought I would mention that it looks like the word “cron” is spelled incorrectly on your website. I’ve seen some tools to help with problems like this such as SpellAlert.com or WebsiteChecker.com. I just thought you should know!

    -John

Leave a Reply

Your email address will not be published. Required fields are marked *