Mike's face
Saturday, October 20th, 2018








PHP HowTo 5

Tuesday January 18, 2005 21:59

How to build and install php 5 on a common Linux installation.  I've had the usual nightmare downloading, unpacking, bumping my head into one issue after another.  I've made notes, which hopefully will be helpful to others.

These instructions worked with Fedora Core 1 at the time of this writing.

Download php 5, openssl, imap, apache

$ wget http://ca.php.net/get/php-5.0.3.tar.bz2/from/this/mirror
$ wget http://www.openssl.org/source/openssl-0.9.7e.tar.gz
$ wget ftp://ftp.cac.washington.edu/imap/imap.tar.Z
$ wget http://apache.mirror.mcgill.ca/httpd/httpd-2.0.52.tar.gz

Unpack all.  Next, build and install from the unpacked directories.

Build and install openssl:

$ make
$ sudo make install

Build and install imap, fix sloppiness (either php or imap is being sloppy):

$ make slx SSLTYPE=nopwd
$ su
$ cp imapd/imapd /usr/local/sbin
$ chmod +s /usr/local/sbin/imapd
$ chown root. /usr/local/sbin/imapd
$ cd c-client
$ ln -s c-client.a libc-client.a

Build and install Apache:

$ ./configure --enable-ssl --enable-proxy-http --enable-proxy --enable-rewrite --enable-vhost-alias --enable-module=so
$ make
$ sudo make install

If you have a sysv style Linux (Unix) like Redhat, you can install a control script, leaving the existing (if any) httpd control script intact, by creating a httpd2 script:

$ sudo install -m 750 build/rpm/httpd.init /etc/rc.d/init.d/httpd2

You'll now need to adjust the newly created /etc/rc.d/init.d/httpd2 file, using the replace tool, or manually if you don't have that one handy:

$ sudo replace /usr/sbin/ /usr/local/apache2/bin/ /etc/httpd/ /usr/local/apache2/ -- /etc/rc.d/init.d/httpd2

This does 2 search-and-replaces, adjusting the location of apache's bin directory and the configuration base directory.

To make the httpd2 service available, use the chkconfig script, which creates the sysv links for you.  Also stop and disable the previous one, enable and start the new one.  Upon next boot, the new one starts.

$ chkconfig --add httpd2
$ service httpd stop
$ chkconfig httpd off
$ chkconfig httpd2 on
$ service httpd2 start

You should be able to point your browser to localhost and apache2 should work.  Now all the fun stuff to configure apache to do all the stuff you'll need it do, you'll have to do, probable by integrating /etc/httpd/conf/* stuff into /usr/local/apache2/conf/*.  Good luck with that one.  I know mine is complicated with all kinds of virtual host stuff, ssl stuff, the high maintenance twiki stuff, etc.

I had some additional fun.  My server system was missing bison, flex, libxml2, pam, kerberos (shishi), latest mysql.  I'd first try the final step, building and installing php, and come back to this step if needed, and execute the parts you think you need.

$ cd ~/tmp
$ wget http://ftp.gnu.org/gnu/bison/bison-2.0.tar.gz
$ tar xzf bison-2.0.tar.gz
$ cd bison-2.0
$ ./configure
$ make
$ sudo make install

$ cd ~/tmp
$ wget http://ftp.gnu.org/non-gnu/flex/flex-2.5.4a.tar.gz
$ tar xzf flex-2.5.4a.tar.gz
$ cd flex-2.5.4
$ ./configure
$ make
$ sudo make install

$ cd ~/tmp
$ wget http://xmlsoft.org/sources/libxml2-2.6.17.tar.gz
$ tar xzf libxml2-2.6.17.tar.gz
$ cd libxml2-2.6.17
$ ./configure
$ make
$ sudo make install

$ cd ~/tmp
$ wget http://www.kernel.org/pub/linux/libs/pam/pre/library/Linux-PAM-0.78.tar.gz
$ tar xzf Linux-PAM-0.78.tar.gz
$ cd Linux-PAM-0.78
$ ./configure
$ make
$ sudo make install  (it might ask some fun questions here)

$ cd ~/tmp
$ wget ftp://alpha.gnu.org/pub/gnu/shishi/shishi-0.0.21.tar.gz
$ tar xzf shishi-0.0.21.tar.gz
$ cd shishi-0.0.21
$ ./configure
$ make
$ sudo make install

Finally, build and install php.  Adjust /home/mike/tmp accordingly.

$ ./configure --enable-trans-sid --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --enable-exif --with-gd --with-pdflib --with-zlib --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-tiff-dir=/usr/local --with-imap=/root/tmp/imap-2004b --with-imap-ssl --with-openssl=/usr/local/ssl/
$ make
$ sudo make install

(C) Copyright 2004-2007 Mike Pot