Wed 13 Sep 2006
DRAFT POSTING
I want to upgrade the installation of php on my server as I feel it is important to keep abreast of the bug fixes in core applications, especially the popular ones which will be subject to the most abuse.
Required packages:
- gdbm (a set of database routines that use extensible hashing)
- bison (general-purpose parser generator that converts an annotated context-free grammar into an LALR(1) or GLR parser for that grammar)
- flex (A fast lexical analyser generator for generating programs that perform pattern-matching on text.)
- php
Optional packages:
- For IMAP support:
- IMAP
- Kerebos
- Pinfo
- For DB3 support:
- Berrkley DB
- AOP
- For Interbase support:
- Interbase
- AOP
Building the libraries
gdbm
The source files for gdbm are available by FTP from the GNU servers. Open a connection to their server and download the latest version (1.8.3 at the time of writing)
# ftp ftp.gnupg.org
# login: anonymous password:anon@
# cd gnu/gdbm
# passive
# dir gdbm-*
# get gdbm-1.8.3.tar.gz
# quit
Next we need to unzip the file we have just downloaded and change to the directory
# gunzip -c gdbm-1.8.3.tar.gz|tar x
# cd gdbm-1.8.3
Then we need to run autoconfigure. As we do not have root access, we need to specify an alternative location for the build. I have chosen /usr/mylocal. We will redirect the output to a couple of files so that we do not miss anything.
# ./configure --prefix=/usr/mylocal >log.config 2>err.config
Check that no errors were encountered and fix any that were logged before proceeding further.
#ls -l err.config
#less err.config
Build the package and check for any errors
#make >log.make 2>err.make
#ls -l err.make
#less err.make
Install the gdbm package
#make install>log.install 2>err.install
#ls -l err.install
#less err.install
bison
We need to follow the same procedure to build the bison library.
# ftp ftp.gnupg.org
# login: anonymous password:anon@
# cd gnu/bison
# passive
# dir bison-*
# get bison-2.3.tar.bz2
# get bison-2.3.tar.bz2.sig
# quit
# gpg --verify bison-2.3.tar.bz2.sig
# bunzip2 -c bison-2.3.tar.bz2 | tar x
# cd bison-2.3
# ./configure --prefix=/usr/mylocal >log.config 2>err.config
# make >log.make 2>err.make
# make install >log.install 2>err.install
flex
#wget http://easynews.dl.sourceforge.net/sourceforge/flex/flex-2.5.33.tar.bz2
# bunzip2 -c flex-2.5.33.tar.bz2|tar x
# cd flex-2.5.33
# ./configure --prefix=/usr/mylocal >log.config 2>err.config
# make check >log.check 2>err.check
# make >log.make 2>err.make
# make install >log.make 2>err.make
IMAP Support
ncurses
# ln -s /usr/mylocal/inc/
Pinfo
# wget http://alioth.debian.org/frs/download.php/1498/pinfo-0.6.9.tar.bz2 # wget http://alioth.debian.org/frs/download.php/1499/pinfo-0.6.9.tar.bz2.sig # gpg --verify pinfo-0.6.9.tar.bz2.sig # bunzip2 -c pinfo-0.6.9.tar.bz2 |tar x # cd pinfo-0.6.9 # ./configure --prefix=/usr/mylocal --with-curses=/usr/mylocal >log.config 2>err.config # make >log.make 2>err.make # make install >log.install 2>err.install
Kerebos
IMAP
Build php
php requires the header file for gdbm.h to be in one of four locations, so create a link in /usr/local/include. First, however, we need write access rights to the # chmod u+w /usr/local/include # ln -s /usr/mylocal/include/gdbm.h /usr/local/include/gdbm.h # chmod u-w /usr/local/include
Download the latest source from php.net directly to your server:directory.
- wget http://uk.php.net/get/php-4.4.4.tar.bz2/from/www.php.net/mirror
Extract the source files using the command gunzip - c php-4.x.x.tar.gz|tar x and then change into the directory you have just created (cd php-4.x.x)
If you already have php installed (as I do), then create a file called phpinfo.php and place it in your webserver's home directory so that you can run it. It should contain the following code:
-
<?php
-
?>
When you run this code, it will display the current configuration for your version of php. Copy it for this new build and add the bits in bold. Your configuration command should look something like this and needs to be on one line:
./configure --prefix=/usr/mylocal --with-apxs=/usr/sbin/apxs --with-gd --with-jpeg-dir=/usr/lib --with-gettext=/usr --enable-safe-mode --with-config-file-path=/etc/httpd --with-exec-dir=/usr/bin --with-zlib --enable-magic-quotes --with-regex=system --with-ttf --with-db --with-gdbm --enable-mbstring --enable-mbstr-enc-trans --enable-track-vars --enable-wddx=shared --enable-mm=shared --enable-xml --enable-ftp --disable-debug --with-libdir=/usr/lib --with-db3 --with-interbase=shared --with-pgsql=shared --with-ldap --with-imap --with-pdflib=shared --enable-sockets >log.config 2>err.config
If you get the error configure: error: no acceptable cc found in $PATH, then you do not have a compiler installed. Try something like GCC
--with-imap
error: Cannot find rfc822.h.
Possible SOLUTION: Download and build latest imap.tar.Z from ftp://ftp.cac.washington.edu/imap/ and Kerebos from http://web.mit.edu/Kerberos/dist/krb5/1.5/krb5-1.5.1-signed.tar
The following options are causing problems:
--with-gettext=/usr --with-exec-dir=/usr/bin --with-libdir=/usr/lib
--with-db3
error: Header contains different version
Possible SOLUTION: Missing header files. Download and install BerkleyDB from http://www.oracle.com/technology/software/products/berkeley-db/index.html Current version is 4.5.20, so download is wget http://download-west.oracle.com/berkeley-db/db-4.5.20.tar.gz
Alternative location (for db3) http://packages.slackware.it/package.php?q=current/db3-3.3.11-i486-4
--with-interbase=shared
error: libgds or libib_util not found!
Possible SOLUTION: Download interbase 6.01 from ftp://ftpc.borland.com/pub/interbase/devsupport/open_source/ib_source601.tar.gz
--with-pdflib=shared --with-jpeg-dir=/usr/lib --with-zlib
error:
PDFlib extension requires at least pdflib 3.x. You may also need libtiff, libjpeg, libpng and libz. Use the options --with-tiff-dir=<DIR>, --with-jpeg-dir=<DIR>, --with-png-dir=<DIR> and --with-zlib-dir=<DIR>
Possible SOLUTION: Download PDFLite (for private use) or purchase license from PDFLib
which leaves
./configure --prefix=/usr/mylocal --with-apxs=/usr/sbin/apxs --with-gd --enable-safe-mode --with-config-file-path=/etc/httpd --enable-magic-quotes --with-regex=system --with-ttf --with-db --with-gdbm --enable-mbstring --enable-mbstr-enc-trans --enable-track-vars --enable-wddx=shared --enable-mm=shared --enable-xml --enable-ftp --disable-debug --with-pgsql=shared --with-ldap --enable-sockets --with-mysql=/usr/local/mysql
then type:
make
If you get the error make: *** No targets specified and no makefile found. Stop., then configure did not work properly. Go back and check log.config for the problem. If configure worked properly, then it should contain the following sections:
- Configuring SAPI modules
- Running system checks
- General settings
- Configuring extensions
- Configuring PEAR
- Configuring Zend
- Configuring TSRM
- Configuring libtool
- Generating files
before ending with
- Thank you for using PHP.
and then:
make install
backup your php.ini file:
cp php.ini.bak /etc/httpd/php.ini
you will need to edit your php.ini file now:
pico -w /etc/httpd/php.ini
register_globals = Off
change to register_globals = On
PHP tends to make some changes to your httpd.conf file so you may need too edit it:
pico -w /etc/httpd/conf/httpd.conf
add this line:
LoadModule php4_module /usr/lib/apache/libphp4.so
put it in the #Extra Modules area of the file.
save your changes and now just one more file too edit:
pico -w /etc/httpd/conf/srm.conf
add this line:
AddType application/x-httpd-php .php .php4 .phtml
save your changes, then stop and start httpd:
/etc/rc.d/init.d/httpd restart
(i know this seems similar to other tuts but i learnt from other tuts around this forum and other forums so my way of installing is similar)
This works i have tested it on my machine here at work.
If you get the error configure: error: png.h not found. when you try make install, then install LibPNG
The instructions above suggest including "--with-imap" in the configure line. This was a major problem on my RaQ 550, although I really wanted IMAP support. The error messages in config.log were:
configure:40552: checking whether IMAP works configure:40585: gcc -o conftest -g -O2 -Wl,-rpath,/usr/local/lib -L/usr/local/lib conftest.c -lc-client -lssl -lcrypto -lcrypt -lpam -lttf -lpng -lz -lz -lgdbm -lz -lssl -lcrypto -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 /usr/lib/libc-client.a(mail.o): In function `mm_cache': /usr/src/redhat/BUILD/imap-2002d/c-client/mail.c:203: undefined reference to `__canary_death_handler'
Temporarily moving the (non-stackguard) GCC compiler, and linking the StackGuard version of GCC to the default location makes it work.
# mv /usr/bin/gcc /usr/bin/gcc.bak # ln -s /usr/sg/bin/gcc /usr/bin/gcc
Now head over to your PHP source folder and do a standard configuration..
# cd php-4.3.4 # ./configure --configure-options
... finish building PHP, and be sure to move the original GCC back into place when you are done.
# mv /usr/bin/gcc.bak /usr/bin/gcc

