Upgrade PHP on RaQ 550

From CobaltFAQs

Jump to: navigation, search


Upgrading to PHP v4.4.x

Shell into the server (via SSH) as admin and become root

   su - 

Make working and backup directories

   mkdir -p /home/src/php-backup 
   mkdir -p /usr/lib/apache.adm 

Make a backup copy of libphp4.so

   cp /usr/lib/apache/libphp4.so /home/src/php-backup 

Copy existing PHP stuff to new directory for admin server to use

   cp -r /usr/lib/apache/* /usr/lib/apache.adm

Install libmcrypt

   cd /home/src
   wget http://easynews.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz
   tar zxf libmcrypt-2.5.7.tar.gz
   cd libmcrypt-2.5.7
   make check
   make install

Build the new PHP

To build with IMAP support

   export CC=/usr/sg/bin/gcc 

NOTE: This uses the StackGuard-enabled gcc compiler, which makes the PHP compatible with the StackGuard-enabled IMAP binaries from Sun.

   cd /home/src 

Get php-4.4.2.tar.gz onto the RaQ via wget, ftp, etc.

   tar zxf php-4.4.2.tar.gz 
   cd php-4.4.2 
  ./configure \
  --prefix=/usr \
  --with-config-file-path=/etc/httpd \
  --with-exec-dir=/usr/bin \
  --with-apxs=/usr/sbin/apxs \
  --enable-calendar \
  --enable-ftp \
  --enable-magic-quotes \
  --enable-mbstring \
  --enable-mbstr-enc-trans \
  --enable-safe-mode \
  --enable-sockets \
  --enable-track-vars \
  --enable-xml \
  --disable-debug \
  --with-gd \
  --with-gettext=shared \
  --with-iconv \
  --with-imap \
  --with-interbase=shared \
  --with-jpeg-dir=/usr \
  --with-ldap \
  --with-mcrypt=shared \
  --with-mysql=shared \
  --with-openssl=/usr \
  --with-pear \
  --with-pgsql=shared \
  --with-png-dir=/usr \
  --with-regex=system \

Note: Some people have had better results using --with-mysql instead of --with-mysql=shared above. You may not need to do the Install MySQL library step below if you leave off the =shared...

You may need/want to alter the above ./configure line to your needs. This one is pretty basic.

Then do

   make && make install

"Install" the new MySQL library

   cp /home/src/php-4.4.2/modules/mysql.so /usr/lib/apache/php/mysql.so

Modify admin web server to use old PHP library

The reason for this is so that the internationalization support in the administrative UI doesn't get broken. We haven't "cracked the code" yet to put i18n support into a newer PHP version for the admin UI.

Edit /etc/admserv/conf/httpd.conf. Search for the following line:

   LoadModule php4_module modules/libphp4.so 

and comment it out (makes it easy to switch back). Add a new line:

   #LoadModule php4_module modules/libphp4.so 
   LoadModule php4_module /usr/lib/apache.adm/libphp4.so 

Modify user-space web server to use new PHP library

Edit /etc/httpd/conf/httpd.conf. Search for the following line:

   LoadModule php4_module modules/libphp4.so 

comment it out, and add the line:

   #LoadModule php4_module modules/libphp4.so 
   LoadModule php4_module /usr/lib/apache/libphp4.so 

Note - while you're in httpd.conf you can change the lines

   AddType application/x-httpd-php4 .php3 
   AddType application/x-httpd-php4 .php4 
   AddType application/x-httpd-php4 .php 


   AddType application/x-httpd-php .php .php4 .php3 

You can keep it on multiple lines if you want, but I think it's easier to see all on one line.

PHP build complete, restart the daemons

You're now done with the PHP upgrade. Restart the httpd daemons:

   /etc/init.d/httpd restart 
   /etc/init.d/admserv restart 

admserv should now be running using the original PHP library, and httpd is now running with the new PHP.

Test the new version

To check that the userspace webserver is using the new PHP version, create a test.php file in a website directory. test.php should contain:

   <?php phpinfo(); ?> 

Type the URL into a browser (http://www.example.com/test.php) and it should show the new PHP version.

Clean up after ourselves

When you're sure it's working, go back and delete all the source code etc., so you don't chew up extra disk space for nothing:

   cd /home/src 
   rm -rf php-4.3.9* 

Quit your shell session.

Be sure to use the most recent PHP version !!!

Note: There is a similar procedure at http://the.taoofmac.com/space/HOWTO with more background information.

Upgrading to v5.0.x

A tentative howto for PHP 5.0.1 upgrade from http://www.neomedia.nl/content/view/4/31/


This HOWTO details the steps I took to upgrade a RAQ550 machine to PHP 5.0.1, and is presented more for my own future reference than as a comprehensive setup guide.

Many thanks to Robbert Hamburg, icucreations.com, pointbeing.net and taoofmac.com

This howto was made after testing on a NON-production RaQ 550 with all Sun PKGs installed and with PHP 4.2.3 and MySQL 3.23.54 installed.

  DISCLAIMER: Following this procedure will invalidate your warranty. This is not a
  supported upgrade path, and if you decide to do this, you're on your own. Some 
  people have broken their administrative interface by overlooking a couple of steps 
  and/or failing to make backups of the original Cobalt files - you have been warned.

The base procedure can be outlined as follows:

  • Make httpd.admserv fully independent
  • Get the PHP sources and any dependent libraries you might need
  • Compile PHP for the Cobalt layout

Isolating the admin server

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:

su - 
cd /usr/lib 
cp -R apache apache.admserv 
cp -R apache apache.orig 

Now make the admin web server use the new apache.admserv directory. Edit /etc/admserv/conf/httpd.conf to tell Apache 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).

extension_dir = /usr/lib/apache.admserv/php

Now test it by restarting httpd.admserv:

/etc/rc.d/init.d/admserv reload

and try out the Cobalt UI. So far, everything you have done is easily reversible, and the hosted web sites are still running from /usr/lib/apache.

Installing libxml2

rpm -Uvh ftp://ftp.cobaltsupport.com/pub/RPMS/libxml2-2.6.11-r4cs1.i386.rpm \

Installing zlib

wget http://www.gzip.org/zlib/zlib-1.2.1.tar.gz 
tar –zxvf zlib-1.2.1.tar.gz 
cd zlib-1.2.1 
./configure –prefix=/home/zlib/ 
make install 
cd .. 

Installing expat

From http://sourceforge.net/projects/expat/

wget http://heanet.dl.sourceforge.net/sourceforge/expat/expat-1.95.7.tar.gz 
tar -zxvf expat-1.95.7.tar.gz 
cd expat-1.95.7 
./configure --prefix=/home/expat 
make install 
cd .. 

Installing GD

For dynamic image generation. Details from http://www.boutell.com/gd/. Recent PHP support for GD now makes installation a breeze, though in order to do anything useful, you'll require at least the following libraries.

Installing libjpeg

wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz 
tar -zxvf jpegsrc.v6b.tar.gz 
cd jpeg-6b 
make install 
cd .. 

Installing libpng

http://libpng.sourceforge.net/. Slightly odd this one, so take care. There's no configure but you need to make sure you get the right makefile for your system.

wget http://heanet.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.5.tar.gz 
tar -zxvf libpng-1.2.5.tar.gz 
cd libpng-1.2.5 
cp scripts/makefile.linux makefile 
make install 
cd .. 

Get and build PHP 5

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

get the PHP tarball
tar -zxvf php-5.0.1.tar.gz 
mv php-5.0.1 /usr/src/ 
cd /usr/src/php-5.0.1
./configure \
--prefix=/home/php \ 
--with-apxs=/usr/sbin/apxs \
--with-gd \
--with-jpeg-dir=/home/php \
--with-png-dir=/home/png \
--enable-gd-native-ttf \
--with-xml \
--with-libxml-dir=/home/php \
--with-expat-dir=/home/expat/lib \
--with-dom=/home/php \
--enable-ftp \
--with-mysql=/home/mysql \
--enable-shared=yes \
--enable-static=yes \
--enable-magic-quotes \
--enable-track-vars \
--enable-sockets \
--enable-wddx \
--with-xmlrpc \
--with-zlib-dir=/home/zlib/include \
--with-iconv \
--enable-libxml \

Robbert pointed out to me that I omitted a couple of rather important switches. I haven't been able to successfully make && make install with these switches but I'll list them anyway.

--with-regex=system \
--with-openssl=/usr \
--with-pgsql=shared \
--with-mcrypt=shared \
--with-imap \
--with-imap-ssl \
--with-interbase=shared \
--disable-debug \
--enable-mbstring \
--enable-mbstr-enc-trans \
 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; taking special care to change the extension_dir to the new one PHP creates upon installation

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.

Last thing I had to do was to correct the following warning when restarting httpd:

 Setting up web service: httpd
 [Wed Sep 1 11:06:55 2004] [warn] module  mod_php5.c is already added, skipping

I corrected this by commenting

 #AddModule mod_php5.c

in httpd.conf

Personal tools