skyBuilders HomePage    Howto Build php5
Jesse Burkhardt

NOTES on COMPILING PHP5

The following is a step by step desciption of how I built php5. Included are URLs for wget'ing all required packages and all Linux commands used in the php5 build process. (Our build necessitated our building of PostgreSQL (7.4.3) and Apache (2.0.50).)

** Before attempting to build PHP5 it is important to first build PostgreSQL (7.4.3) and then PHP5, followed by Apache (2.0.50). Although it is possible to have multiple versions of the same services running on a single computer such a practice will not be discussed in this document. Therefore, please remember to erase all RPMs that may be associated with prior versions of these already installed.

I. General

Packages or individual files we have retieved for the overall php5 build process:

apr-util-devel-0.9.4-14.i386.rpm
apt-0.5.15cnc6-1.1.fc2.fr.i386.rpm
apt-devel-0.5.15cnc6-1.1.fc2.fr.i386.rpm
c-client_archive3.gz
DB-1.6.5.tgz
freetype-2.1.9.tar.gz
httpd
httpd-2.0.50.tar.gz
httpd-devel-2.0.49-4.i386.rpm
imap-2004a.tar.Z
libjpeg-devel-6b-31.1.i386.rpm
libmcrypt-2.5.7.tar.gz
libmysqlclient-lgpl_3.23.56.orig.tar.gz
libpng-1.0.15-1.i386.rpm
libpng-devel-1.2.5-8.i386.rpm
libxslt-1.1.9-1.i386.rpm
libxslt-devel-1.1.9-1.i386.rpm
mhash-0.9.1.tar.gz
mod_perl-1.99_12.tar.gz
pcsc-lite-libs-1.1.1-2.i386.rpm
perl.conf
php-5.0.1.tar.gz
php.conf
postgresql-7.4.3.tar.gz
README
tidy_src.tgz
unixODBC-2.2.9.tar.gz

All of the above are contained at http://fs.skybuilders.com/dev/php5/php5-packages.tar

1.) Installed apt-get for Fedora RPM retreivals. This is advisable to save yourself the headache of wading through recursive rpm retievals and intalls. (For installation instructions see http://www.linuxcompatible.org/thread27839-1.html.)
% wget http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/2/apt/
    apt-0.5.15cnc6-1.1.fc2.fr.i386.rpm
% wget http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/2/apt/
    apt-devel-0.5.15cnc6-1.1.fc2.fr.i386.rpm
% rpm -Uvh apt-0.5.15cnc6-1.1.fc2.fr.i386.rpm 
    apt-devel-0.5.15cnc6-1.1.fc2.fr.i386.rpm
% apt-get update
Run this twice
% apt-get update
Ignore instructions for 'synaptic' graphical front end.

2.) After installing apt-get use it to get several packages:
% apt-get install httpd-devel
3.) All rpms provided with our php5-packages tar file must be installed before configuring php5.

II. PostgreSQL

1.) PostgreSQL 7.4.3 Installation:

NB: Uninstall any prior version of PostgreSQL before proceeding:
% rpm -e postgresql-server
% rpm -e postgresql
Then proceed with your installation:
% wget ftp://ftp3.us.postgresql.org/pub/postgresql/source/v7.4.3/
    postgresql-7.4.3.tar.gz
Untar and build PostgreSQL in /usr/local/src, following short instructions in /usr/local/src/postgresql-7.4.3/INSTALL.

Here is an excerpt of the key lines:
% ./configure
% gmake
% su
% gmake install
% adduser postgres
% mkdir /usr/local/pgsql/data
% chown postgres /usr/local/pgsql/data
% su - postgres
% /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
% /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
% /usr/local/pgsql/bin/createdb test
% /usr/local/pgsql/bin/psql test
% exit
Then edit /etc/profile as follows
# BEGIN skybuilders customization
pathmunge /usr/local/pgsql/bin after
LD_LIBRARY_PATH=/usr/local/pgsql/lib
MANPATH=/usr/local/pgsql/man:$MANPATH
# END skybuilders customization
Also edit /usr/local/pgsql/data/postgresql.conf, changing the tcpip_socket setting and uncommenting the port setting line, as follows:
# BEGIN skybuilders mod
#tcpip_socket = false
tcpip_socket = true
max_connections = 100
   # note: increasing max_connections costs about 500 bytes of shared
   # memory per connection slot, in addition to costs from shared_buffers
   # and max_locks_per_transaction.
#superuser_reserved_connections = 2
#port = 5432
port = 5432
# END skybuilders mod
To daemonize it:
% cp /usr/local/src/postgresql-7.4.3/contrib/start-scripts/linux 
    /etc/init.d/postgresql
% chmod +x /etc/init.d/postgresql
% chkconfig --add postgresql
% service postgresql restart
III. php5

1.) Needed to get imap distrabution for build pieces:
% wget ftp://ftp.cac.washington.edu/imap/imap-2004a.tar.Z
Run the make (no './configure' required) with the RedHat (lrh) argument:
% make lrh
All we are doing is creating certain components to be copied for PHP5, so we don't need to do any other build steps thatn the one above.

After untarring and compiling it needed to copy certain pieces:
% cp /usr/local/src/imap-2004a/c-client/c-client.a  /usr/lib/libc-client.a
% cp /usr/local/src/imap-2004a/c-client/rfc822.h  /usr/include/
% cp /usr/local/src/imap-2004a/c-client/mail.h  /usr/include/
% cp /usr/local/src/imap-2004a/c-client/linkage.h /usr/include
2.) Get, untar and make the libmcrypt package into /usr/local/src:
% wget http://easynews.dl.sourceforge.net/sourceforge/mcrypt/
    libmcrypt-2.5.7.tar.gz
% tar zxvf libmcrypt-2.5.7.tar.gz
% cd /usr/local/src/libmcrypt-2.5.7
% ./configure
% make
% make install
% cp /usr/local/src/libmcrypt-2.5.7/lib/mcrypt.h  /usr/include
3.) Get, untar and make the libmhash package into /usr/local/src:
% wget http://umn.dl.sourceforge.net/sourceforge/mhash/mhash-0.9.1.tar.gz
Repeat build steps above. And:
% cp /usr/local/src/mhash-0.9.1/lib/mhash.h /usr/include/
4.) And the same for libmysqlclient:
% wget http://http.us.debian.org/debian/pool/main/libm/libmysqlclient-lgpl/
    libmysqlclient-lgpl_3.23.56.orig.tar.gz
Build this; this requires no header or lib files to be copied.

5.) For pspell (spell checker) go to http://aspell.sourceforge.net We need to download only the aspell package and dictionaries of our choosing for PHP5 to configure with the pspell option.
% wget ftp://ftp.gnu.org/gnu/aspell/aspell-0.50.5.tar.gz
% tar zxvf aspell-0.50.5.tar.gz
% wget ftp://ftp.gnu.org/gnu/aspell/dict/en/aspell5-en-6.0-0.tar.bz2
% tar jxvf aspell5-en-6.0-0.tar.bz2
% cd /usr/local/src/aspell-0.50.5
% ./configure && make
% make install
% cd /usr/local/src/aspell5-en-6.0-0
% ./configure && make
% make install
6.) For tidy and libtidy (source as of 2004/08/11):
% wget http://tidy.sourceforge.net/src/tidy_src.tgz
You may need to add execute privileges to the setup.sh configurator script:
% cd /usr/local/src/tidy
% chmod +x build/gnuauto/setup.sh
From the top source tree:
% build/gnuauto/setup.sh
Then do a regular build:
% ./configure --prefix=/usr
% make
% make install
7.) For unixODBC (required for PEAR):
% wget http://www.unixodbc.org/unixODBC-2.2.9.tar.gz
% tar zxvf unixODBC-2.2.9.tar.gz
% cd unixODBC-2.2.9
We want to build a non-GUI version of this so that we get no X include errors.
% ./configure --enable-gui=no
% make 
% make install
8.) We will need to build and install Freetype2 support, untar and go to source dir, then run 'make' twice:
% cd /usr/local/src/freetype-2.1.9
% make
% make
We need to now copy the freetype2 include dir to the /usr/linclude tree:
% mkdir /usr/include/freetype2
9.) Next we need to install XSLT libs (devel also):
% rpm -Uvf /usr/local/src/php5-packages/libxslt-1.1.9-1.i386.rpm
% rpm -Uvf /usr/local/src/php5-packages/libxslt-devel-1.1.9-1.i386.rpm
10.) For the PHP5 PostgreSQL extentions we need to copy accordingly:
% cp /usr/local/pgsql/include/libpq-fe.h /usr/include/
% cp /usr/local/pgsql/include/postgres_ext.h /usr/include/
% cp /usr/local/pgsql/include/libpq/libpq-fs.h /usr/include/
% mkdir /usr/include/libpq
% cp /usr/local/pgsql/include/libpq/libpq-fs.h /usr/include/libpq
11.) Building PHP5

Get and untar the PHP5 sources.

For PostgreSQL, assumes you have it already installed:
# unsure about this one: % cp /usr/local/src/php-5.0.1/netware/libpq-fe.h  
    /usr/include/
% cd /usr/lib
% ln -s libpq.so.3.1 libpq.so

% cd /usr/lib
% ln -s libjpeg.so.62.0.0 libjpeg.so

% rpm -Uvh libpng-devel-1.2.5-8.i386.rpm

% cd /usr/local/src/php-5.0.1
The php5 config command looks as follows:
% ./configure --host=i386-redhat-linux --build=i386-redhat-linux
--target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr 
--exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin 
--sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include 
--libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var 
--sharedstatedir=/usr/com --mandir=/usr/share/man 
--infodir=/usr/share/info  --cache-file=../config.cache 
--with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d
--enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath
--enable-inline-optimization --with-bz2 --with-db4=/usr --with-curl
--with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr
--with-gd --enable-gd-native-ttf --without-gdbm --with-gettext 
--with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl 
--with-png --with-regex=system --with-xml --with-expat-dir=/usr 
--with-dom=shared,/usr --with-dom-xslt=/usr --with-dom-exslt=/usr 
--with-xmlrpc=shared --with-zlib --with-layout=GNU --enable-bcmath 
--enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode 
--enable-sockets --enable-sysvsem --enable-sysvshm --enable-track-vars
--enable-trans-sid --enable-yp --enable-wddx --with-pear=/usr/share/pear
--with-imap=/usr/local/imap-2004a --with-kerberos --with-ldap=shared
--with-mysql=shared,/usr --with-pgsql=shared,/usr 
--with-unixODBC=shared,/usr --enable-memory-limit --enable-bcmath 
--enable-shmop --enable-calendar --enable-dbx --enable-dio --enable-mcal
--enable-mbstring --enable-mbstr-enc-trans --enable-mbregex 
--with-apxs2=/usr/sbin/apxs --with-mhash --with-tidy  --with-mcrypt 
--enable-simplexml --enable-soap --with-xsl --with-libxml-dir=/usr 
--with-pspell
It is useful to run the make command through a tee pipe to both see and save the output. Some redirection is required to save the error output too:
% make 2>&1 | tee makephp5.log
% make install
% libtool --finish /usr/local/src/php-5.0.1/libs
Once the php5 make and make install steps have succeeded it is necessary to rebuild Apache 2.0 so that the new php_mod libs are incorporated into it. 12.) Misc, php.ini (save the original if you have one):
% cp /usr/local/src/php-5.0.1/php.ini-recommended /etc/php.ini
% cp /usr/local/src/php-5.0.1/modules/* /usr/local/lib/
Now edit the /etc/php.ini file thusly:
; Directory in which the loadable extensions (modules) reside.
#extension_dir = "./"
extension_dir = "/usr/local/lib/"

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
include_path = ".:/php/includes:/usr/share/pear"
Edit the /etc/ld.so.conf file to add the lib path /usr/local/lib; then run the ldconfig command.

12.) At this point it is wise to enable PEAR database abstraction functionality. (PEAR is bundled with php, so you do not have to actually fecth and install it.)
% pear install DB
IV. Apache

NB: You may need to uninstall apache before proceeding:
% rpm -e system-config-httpd
% rpm -e httpd-devel
% rpm -e httpd
1.) Get and build it.
% wget http://apache.towardex.com/httpd/httpd-2.0.50.tar.gz

% ./configure --prefix=/usr/local --enable-ssl --enable-dav 
    --enable-vhost-alias --enable-speling --enable-so
% make
% make install
2.) To run it - assuming you have stopped the prior version of it:

Edit the /usr/local/conf/httpd.conf file, adding:

Look for the user switch section:
#User nobody
#Group #-1
User apache
Group apache
Add the following lines towards the end of the file:
NameVirtualHost *:80

<Directory /var/www/>
    CheckSpelling on
</Directory>

<VirtualHost *:80>
    ServerName gemini.skybuilders.com
    DocumentRoot /var/www/gemini.skybuilders.com
    ServerAdmin jesse@skybuilders.com
    ErrorLog logs/gemini.skybuilders.com-error_log
    CustomLog logs/gemini.skybuilders.com-access_log common
    DirectoryIndex index.html
    AddType application/x-httpd-php .php .php4 .php3 .phtml .html 
	    .xsd .xml .rss .rdf .rdfs
</VirtualHost>

Also look for:

<IfModule mod_ssl.c>
  Include conf/ssl.conf
</IfModule>

And add:

#<IfModule mod_php5.c>
    Include conf/php.conf
#</IfModule>
#<IfModule mod_perl.so>
    Include conf/perl.conf
#</IfModule>
3.) Build mod_perl:
% perl Makefile.PL MP_APXS=/usr/local/bin/apxs
% make && make test
% make install
Locate mod_perl.so and then make sure that your /usr/local/conf/perl.conf file refers to the proper path: 4.) Get some extra httpd conf files from the php5-packages tar file:
% cp /usr/local/src/php5-packages/php.conf /usr/local/conf/
% cp /usr/local/src/php5-packages/perl.conf /usr/local/conf/
% /usr/local/bin/apachectl start
5.) Copy the Fedora deamonization script file accordingly and daemonize it:
% cp /usr/local/src/php5-packages/httpd /etc/rc.d/init.d/
% chkconfig --add httpd
% chkconfig --level 345 httpd on
% chkconfig --list httpd
% service httpd start
Also, if a previous version RedHat was deamonized the following edit will appropriately update the the apache service script (/etc/rc.d/init.d/httpd):
# BEGIN skybuilders mod
#apachectl=/usr/sbin/apachectl
apachectl=/usr/local/bin/apachectl
#httpd=${HTTPD-/usr/sbin/httpd}
httpd=${HTTPD-/usr/local/bin/httpd}
# END skybuilders mod

Edit  |  workFlow  |  Subscribe  |
 Comments (0)
Language: fr  | it  | de  | es  | pt  | ar  | he  | da  | nl  | zh  | ja  | ko  | none 
Author: jesse
skyCalendar

This Version:
Archived at: http://www.skybuilders.com/Users/Jesse/Docs/php5_howto_build.20041006191612.html

Requests
 Version: 503 | Series: 503 

Search: Site | Web | Groups