# RAQ550/Packages/PHP

Update: This Wiki node is deprecated, mostly because I've given up using Cobalt boxes until I can get a more modern Linux running on them. In the meantime, I've found a HOWTO on Setting up PHP 5.0.1 that might be useful for whoever lands here.

One of my stated goals for the RAQ550 is to recompile PHP with XSLT,gd and Freetype support for it.

The necessary steps (and dependencies) will be annotated here as time allows.

So far:

• gdbm installs OK.
• rebuilding the libxml2 SRPM breaks on its Python submodule
• Python is an entirely new kettle of fish. Editing the SPEC file properly takes some doing.
• I have absolutely no bloody idea of why I should need jdkgcj, but it compiles and installs after editing the SPEC file to remove gcc 3.2 version checks

After reading the Sun KB notes (link axed by Sun, but kept here for future reference) on recompiling PHP for the Qube3, I was able to successfully recompile PHP 4.3.2 on a RAQ550.

The trick is to ensure that the base httpd and the administration server (httpd.admserv) do not collide in any way - httpd.admserv employs at least one custom extension (cce.so, which interfacest to the Cobalt administration framework) and the administration scripts will only run correctly on the built-in PHP 4.0.6 interpreter (which is one reason why it never got updated).

The steps below were performed on two RAQ3 machines converted to RAQ550s, and do not (by any means) ensure that the rest of the RAQ550 hosting features (such as Java Server Pages, ASPs, etc.) work correctly (I don't use them, or at least the simple scripts I have in those languages work OK). Perl CGIs (and other CGIs in general) are not affected by this, but recompiling PHP with some extra libraries may cause other modules to break. You have been warned.

---- DRAFT FROM HERE ON DOWN ----

The base procedure can be outlined as follows:

• Get the PHP sources and any dependent libraries you might need
• Compile PHP for the Cobalt layout
• Enjoy

Go to /usr/lib and copy /usr/lib/apache to /usr/lib/apache.admserv. For good measure, make another copy called apache.orig, since you will change the apache directory contents as well later on, and backups are always nice to have:

# cd /usr/lib
# cp -R apache apache.orig

Now let's make the administration server use the new apache.admserv directory: Edit the administration server's httpd.conf file to load the PHP module from /usr/lib/apache.admserv/libphp4.so. The relevant line in the file should look like this:

# cat /etc/admserv/conf/httpd.conf | grep LoadModule | grep -i php4
LoadModule /usr/lib/apache.admserv/libphp4.so

Now PHP has to be configured to load the custom cce.so extension. Edit the administration server's php.ini file to load extensions from /usr/lib/apache.admserv/php.

This is different from the /etc/httpd/php.ini file used by the hosted sites, since the startup scripts for each web server set the PHPRC environment variable (reading through /etc/rc.d/init.d/httpd and /etc/rc.d/init/admserv is strongly recommended for those who want to compare the hosting web server with the admin server).

Again, the relevant line is:

# cat /etc/admserv/php.ini | grep extension_dir
extension_dir = /usr/lib/apache.admserv/php

Not test it by restarting httpd.admserv:

# /etc/rc.d/init.d/admserv restart

And test it by going to the administration front-end. So far, everything you have done is easily reversible, and the hosted web sites are still running from /usr/lib/apache.

Information on recompiling PHP was axed from the Sun Knowledge Base, so here are the command lines I used:

# cd /root/Packages
# tar -zxvf php-4.3.2.tar.gz
# mv php-4.3.2 /usr/src/
# wget http://www.libpng.org/pub/png/src/libpng-1.2.5.tar.gz
# cd ..
# mkdir Build
# cd Build/
# tar -zxvf ../Packages/libpng-1.2.5.tar.gz
# cd libpng-1.2.5/
# ./configure ; make
# cp scripts/makefile.linux Makefile
# make install
# cd ../../Packages/
# wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
# cd ../Build/
# tar -zxvf ../Packages/jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure ; make
# make install
# make install-lib
# make install-headers

I then searched for libttf - don't remember if it's already installed on the 550 - and proceeded to recompile PHP with the following command line (you can get the command-line used to compile any version of PHP by reading the phpinfo() output - check your PHP manual).

# cd /usr/src/php-4.3.2/
# ./configure --prefix=/usr --with-apxs=/usr/sbin/apxs --enable-safe-mode \
--with-config-file-path=/etc/httpd/ --with-exec-dir=/usr/bin --with-zlib \
--enable-magic-quotes --with-regex=system --with-pear --enable-calendar \
--with-gd --with-iconv --disable-debug --with-gettext \
--with-ttf=/usr/lib/libttf.so --enable-mbstring --with-interbase=shared \
--with-mysql=shared --with-pgsql=shared --with-jpeg=/usr/local/lib \
--with-png=/usr/local/lib
# make
# make install
# cp modules/* /usr/lib/apache/php/
# /etc/rc.d/init.d/httpd restart

I then proceeded to change php.ini to my settings.

Note: If you have installed any Apache or PHP updates from Cobalt (at least any after June 2003), it might actually be a good idea to rename /usr/lib/apache temporarily to something else and make doubly sure that the administration server is not using anything in that directory - any new updates or third-party extensions may well add more stuff to that directory that I'm not aware of.