[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-developers] FAQ: installing PHP4 on a Qube2




FAQ: Steps for installing PHP4 (4.0.2) on a Qube2:

NOTES:

* lines surrounded by backticks (`stuff`) are shell commands. If the content between the backticks word-wraps, it should still all be pasted/typed on a single line as a single command. Don't copy/paste/type the backtick characters ;)

* this is basic install info ... I noticed alot of people asking for it on the list archives without a solid resolution. Nothing extra (like postgres support, etc) has been added. This document doesn't attempt to do such nice things as making PHP4 cooperate with PHP3 ... if you need that, you probably don't need this document, or you can modify it to suit your needs.

* there's a good chance there are easier ways to this ... by all means, make an edit and repost it into this thread ... I don't plan on maintaining this information, I'm just getting the ball rolling :) Compiling this as a DSO for Apache is more difficult (since the Qube2 is missing apxs by default) but this keeps me from worrying that I've taught you how to blow away a newer version of Apache with an older version (the SRPM version of Apache on Cobalt's FTP site is older than the most recent release for the Qube2).

* I don't know if the /usr/local/lib/php.ini file is actually in the right location. It's probably fairly simple to check, but I haven't gotten that far yet, so report back if it needs to be elsewhere.



I. Download the necessary files and save them on your Qube2:

        A. PHP4.0.2 source: http://www.php.net/downloads.php

                1. You might wanna grab the manual, too.

B. 'flex' RPM: ftp://ftp.cobaltnet.com/pub/experimental/flex-2.5.4a-3.mips.rpm

1. This is used to compile PHP ... if you already have 'flex' or 'lex' manually installed you shouldn't need this.

C. Apache SRPM: ftp://ftp.cobaltnet.com/pub/products/qube2/SRPMS/apache-1.3.3-1C2.src.rpm

                1. This is older than the version in the latest Qube2 updates

2. We're only using it to get a copy of 'apxs' that is hopefully close in version to the Apache on your Qube2.

                3. We're not going to use this source to recompile Apache!

II. Getting ready ...

A. Login (telnet/SSH/etc) to your Qube2 as 'root' and change to the directory that you saved the PHP4 source, flex RPM and Apache SRPM.

        B. Install the flex RPM:

           `rpm -i ./flex-2.5.4a-3.mips.rpm`

        C. Unpack the Apache SRC RPM

           `rpm -ihv ./apache-1.3.3-1C2.src.rpm`

D. Unpack the Apache tarball, apply patches and 'make' (but don't 'make install') ... this is needed to properly configure 'apxs.pl' and libraries

           `rpm -bc /usr/src/redhat/SPECS/apache.spec`


        G. Edit 'apxs' to work with the Qube2's perl installation

           `pushd /usr/src/redhat/BUILD/apache_1.3.3/src/support`

`sed 's/#!\/usr\/local\/bin\/perl/#!\/usr\/bin\/perl/' ./apxs > ./tmp ; mv ./tmp ./apxs`

           `sed 's/\@sbindir\@/\/usr\/sbin/' ./apxs > ./tmp ; mv ./tmp ./apxs`

`sed 's/\@includedir\@/\/usr\/src\/redhat\/BUILD\/apache_1.3.3\/src\/include/' ./apxs > ./tmp ; mv ./tmp ./apxs`

`sed 's/\@libexecdir\@/\/usr\/lib\/apache/' ./apxs > ./tmp ; mv ./tmp ./apxs`

`sed 's/\@sysconfdir\@/\/etc\/httpd\/conf/' ./apxs > ./tmp ; mv ./tmp ./apxs`

           `chmod 500 apxs`

           `popd`

III. Configure/Compile/Install PHP4:

        A. Unpack the PHP4.0.2 source code:

           `tar zxvpf php-4.0.2.tar.gz`

        B. Change to the PHP source directory

           `cd php-4.0.2`

        C. Configure PHP to use the copied 'apxs.pl' script

`./configure --with-apxs=/usr/src/redhat/BUILD/apache_1.3.3/src/support/apxs`

        D. Modify the PHP4 Apache DSO Makefile to find the needed libraries

           `pushd sapi/apache`

`sed 's/\$(APACHE_INCLUDE)/\$(APACHE_INCLUDE) -I\/usr\/src\/redhat\/BUILD\/apache_1.3.3\/src\/include -I\/usr\/src\/redhat\/BUILD\/apache_1.3.3\/src\/os\/unix/' ./Makefile > ./tmp ; mv ./tmp ./Makefile`

           `popd`

        E. Make and install PHP4

           `make`

           `make install`

        F. Add the php handler to your srm.conf

`echo 'AddType application/x-httpd-php .php # added for PHP4' >> /etc/httpd/conf/srm.conf`

        G. Copy the php.ini files to /usr/local/lib

           `cp php.ini-dist /usr/local/lib`

           `cp php.ini-dist /usr/local/lib/php.ini`

           `cp php.ini-optimized /usr/local/lib`

IV. Restart Apache and make sure it worked

        A. Stop Apache

           `/etc/rc.d/init.d/httpd.init stop`

        B. Start Apache

           `/etc/rc.d/init.d/httpd.init start`

C. Grep the log to see if it thinks PHP4 is there ... you should see "[Day Mon ## ##:##:## ####] [notice] Apache/1.3.3 Cobalt (Unix) (Red Hat/Linux) PHP/4.0.2 configured -- resuming normal operations"

           `tail /var/log/httpd/home-error | grep PHP`

        D. Create a test file:

`echo '<html><body><?phpinfo()?></body></html>' > /home/groups/home/test.php`

        E. Check it by going to "http://[your qube2]/test.php"

V. Clean up ... only do this once you've verified it installed or you'll have to repeat everything above.

A. Delete the Apache source RPM contents (to be safe since it's an older version)

           `rpm -bp --clean /usr/src/redhat/SPECS/apache.spec`

           `rpm --rmsource /usr/src/redhat/SPECS/apache.spec`

        B. Delete the PHP4 source tree

                `cd ..`

                `rm -rf php-4.0.2`

        C. If you want to delete the files we downloaded in section I.

                `rm apache-1.3.3-1C2.src.rpm`

                `rm flex-2.5.4a-3.mips.rpm`

                `rm php-4.0.2.tar.gz`

        D. Log out

VI. To disable PHP4 processing

        A. Stop Apache

           `/etc/rc.d/init.d/httpd.init stop`

        B. Comment out the Apache configuration lines

           `cd /etc/httpd/conf`

           `cp httpd.conf httpd.conf.php4-enabled`

           `cp srm.conf srm.conf.php4-enabled`

`sed 's/^LoadModule php4_module \/usr\/lib\/apache\/libphp4.so$/#LoadModule php4_module \/usr\/lib\/apache\/libphp4.so/' ./httpd.conf > tmp ; mv ./tmp ./httpd.conf`

`sed 's/^AddModule mod_php4.c$/#AddModule mod_php4.c/' ./httpd.conf > tmp ; mv ./tmp ./httpd.conf`

`sed 's/^AddType application\/x-httpd-php .php/#AddType application\/x-httpd-php .php/' ./srm.conf > tmp ; mv ./tmp ./srm.conf`

        C. Start Apache

           `/etc/rc.d/init.d/httpd.init start`

VII. To delete all files installed in this procedure

... NOTE: this actually deletes all parts we installed above ... if you just want to disable PHP4, see section VI. above.

        ... Make sure you went through the steps in section V. (Clean up), too

        A. Stop Apache

           `/etc/rc.d/init.d/httpd.init stop`

        B. Delete the Apache configuration lines

           `cd /etc/httpd/conf`

           `cp httpd.conf httpd.conf.php4`

           `cp srm.conf srm.conf.php4`

`sed 's/LoadModule php4_module \/usr\/lib\/apache\/libphp4.so//' ./httpd.conf > tmp ; mv ./tmp ./httpd.conf`

`sed 's/AddModule mod_php4.c//' ./httpd.conf > tmp ; mv ./tmp ./httpd.conf`

`sed 's/AddType application\/x-httpd-php .php.*$//' ./srm.conf > tmp ; mv ./tmp ./srm.conf`

        C. Delete the PHP4 .so module

           `rm /usr/lib/apache/libphp4.so`

        D. Delete the PHP support files

           `rm /usr/local/lib/php.ini*`

           `rm -rf /usr/local/lib/php`

        E. Start Apache

           `/etc/rc.d/init.d/httpd.init start`


/ Geoff Baysinger - Lists@xxxxxxxxxxxxxx
/
/ Any opinions expressed herein are my responsibility and
/ not the result of my employer, demonic possession or
/ any other outside faculty.