home   |   about us   |   our network   |   services   |   contact
» Web Hosting
» Reseller Hosting
» Dedicated Servers
» Managed Web Hosting
» Server Security / Auditing
» Remote Backup / Storage
» Virtual Dedicated Servers
» Support Desk
» Client Login
» Forums
» FAQs
» Help Files
» Acceptable Use Policy
» Client Testimonials
» Dedicated Server Tutorial
» Website Optimization
» Search Engine Optimization
» Web Hosting Tutorials
» Web Programming Tutorials
» Networking Tutorials
» Virtual Server Tutorials
» Resources

Apache 2 and PHP 4 and 5 Installation Guide

This tutorial is designed to help those who would like to install Apache 2 and PHP as mod_php or a DSO module on a UNIX/Linux based system. This tutorial has been tested on Redhat 9 and Redhat 8, as well as FreeBSD. The installation should work fairly similar on each variation of UNIX/Linux. This tutorial will be demonstrated using FreeBSD.

Tip: Don't forget to remove (or at least disable) any rpm or other installed versions of apache.

Since Apache 2.0.42 the API for apache will be kept stable, which means you should be able to upgrade apache without having to upgrade your modules as well.

The following is how to install Apache as a DSO module.

For this tutorial we will be using PHP 4.3.8 and httpd 2.0.51.

TIP: Read the whole tutorial before you start, as some steps make go back or forwards.

1. Download apache from http://httpd.apache.org/

wget ftp://ftp.planetmirror.com/pub/apache/dist/httpd/httpd-2.0.51.tar.gz

2. Download PHP from http://www.php.net/

wget http://au2.php.net/get/php-4.3.8.tar.gz/from/www.php.net/mirror

3. Untar/uncompress the files:

tar zxvf httpd-2.0.51.tar.gz

tar zxvf php-4.3.8.tar.gz

4. Next you need to configure your build, this is done inside the apache source directory (the one you just untared). The ./configure command creates a configuration files which is used while building the application binaries. It also checks for all necessary components (software and system) required for the apache installation.

Installation Directory Options:

--prefix=PREFIX install architecture-independent files in PREFIX - default is: /usr/local/apache2
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX]

Please note the 'make install' command (to be used later) will install binaries into these specified locations.

Other Installation Options:
(Where FEATURE is a feature in httpd)

--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-v4-mapped Allow IPv6 sockets to handle IPv4 connections
--enable-exception-hook Enable fatal exception hook
--enable-maintainer-mode Turn on debugging and compile time warnings
--enable-modules=MODULE-LIST Modules to enable (in a list separated by |)
--enable-mods-shared=MODULE-LIST Shared modules to enable
--disable-access host-based access control
--disable-auth user-based access control
--enable-auth-anon anonymous user access
--enable-auth-dbm DBM-based access databases
--enable-auth-digest RFC2617 Digest authentication
--enable-isapi isapi extension support
--enable-file-cache File cache
--enable-echo ECHO server
--disable-charset-lite character set translation
--enable-charset-lite character set translation
--enable-cache dynamic file caching
--enable-disk-cache disk caching module
--enable-mem-cache memory caching module
--enable-example example and demo module
--enable-case-filter example uppercase conversion filter
--enable-case-filter-in example uppercase conversion input filter
--enable-ldap LDAP caching and connection pooling services
--enable-auth-ldap LDAP based authentication
--enable-ext-filter external filter module
--disable-include Server Side Includes
--enable-deflate Deflate transfer encoding support
--disable-log-config logging configuration
--enable-log-forensic forensic logging
--enable-logio input and output logging
--disable-env clearing/setting of ENV vars
--enable-mime-magic automagically determining MIME type
--enable-cern-meta CERN-type meta files
--enable-expires Expires header control
--enable-headers HTTP header control
--enable-usertrack user-session tracking
--enable-unique-id per-request unique ids
--disable-setenvif basing ENV vars on headers
--enable-proxy Apache proxy module
--enable-proxy-connect Apache proxy CONNECT module
--enable-proxy-ftp Apache proxy FTP module
--enable-proxy-http Apache proxy HTTP module
--enable-ssl SSL/TLS support (mod_ssl)
--enable-optional-hook-export example optional hook exporter
--enable-optional-hook-import example optional hook importer
--enable-optional-fn-import example optional function importer
--enable-optional-fn-export example optional function exporter
--enable-bucketeer buckets manipulation filter
--enable-static-support Build a statically linked version the support binaries
--enable-static-htpasswd Build a statically linked version of htpasswd
--enable-static-htdigest Build a statically linked version of htdigest
--enable-static-rotatelogs Build a statically linked version of rotatelogs
--enable-static-logresolve Build a statically linked version of logresolve
--enable-static-htdbm Build a statically linked version of htdbm
--enable-static-ab Build a statically linked version of ab
--enable-static-checkgid Build a statically linked version of checkgid
--enable-http HTTP protocol handling
--disable-mime mapping of file-extension to MIME
--enable-dav WebDAV protocol handling
--disable-status process/thread monitoring
--disable-autoindex directory listing
--disable-asis as-is filetypes
--enable-info server information
--enable-suexec set uid and gid for spawned processes
--disable-cgid CGI scripts
--enable-cgi CGI scripts
--disable-cgi CGI scripts
--enable-cgid CGI scripts
--enable-dav-fs DAV provider for the filesystem
--enable-vhost-alias mass virtual hosting module
--disable-negotiation content negotiation
--disable-dir directory request handling
--disable-imap server-side imagemaps
--disable-actions Action triggering on requests
--enable-speling correct common URL misspellings
--disable-userdir mapping of requests to user-specific directories
--disable-alias mapping of requests to different filesystem parts
--enable-rewrite rule based URL manipulation
--enable-so DSO capability

Optional Packages:

--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-apr=DIR|FILE prefix for installed APR, path to APR build tree, or the full path to apr-config
--with-apr-util=DIR prefix for installed APU, or path to APU build tree
--with-port=PORT Port on which to listen (default is 80)
--with-z=DIR use a specific zlib library
--with-ssl=DIR SSL/TLS toolkit (OpenSSL)
--with-mpm=MPM Choose the process model for Apache to use. MPM={beos|worker|prefork|mpmt_os2|perchild|leader|threadpool}
--with-module=module-type:module-file Enable module-file in the modules/<module-type> directory.
--with-program-name alternate executable name
--with-suexec-bin Path to suexec binary
--with-suexec-caller User allowed to call SuExec
--with-suexec-userdir User subdirectory
--with-suexec-docroot SuExec root directory
--with-suexec-uidmin Minimal allowed UID
--with-suexec-gidmin Minimal allowed GID
--with-suexec-logfile Set the logfile
--with-suexec-safepath Set the safepath
--with-suexec-umask umask for suexec'd process

If you are not sure which options you would like you do not need to choose any features and can simply run "./configure" in the source directory.

Here is the command we are running:
./configure \
--prefix=/usr/local/apache2 \
--enable-cgi \
--enable-ssl \
--enable-so \
--enable-rewrite \
--enable-mime-magic \
--enable-suexec \
--enable-static-rotatelogs \

Press [Enter]

For the most part you should not have any problems, you will get the script checking to see if your system is compatible and has all the requirements to run.

5. The following command will compile the source into binaries based on the configuration you created in step 4. You can go back to step 4 if you did something wrong and redo the configuration.


This command will spurt out a lot of output which most of it you do not need to know. It is the longest step and can take varying amounts of time on different systems.

6. The following command will move the binaries from the build directory into the locations they need to go on your system.

make install

7. Now that the binaries have been installed on your system you need to start the apache server.

/usr/local/apache2/bin/apachectl start

For future reference you can restart apache 2 by using the following command:

/usr/local/apache2/bin/apachectl restart

Or stop apache 2 using the following command:

/usr/local/apache2/bin/apachectl stop

8. You test this is running by using the following command on UNIX (must be on the same machine as apache):

telnet localhost 80

You should receive something like the following:

Connected to localhost.
Escape character is '^]'.
<title>501 Method Not Implemented</title>
<h1>Method Not Implemented</h1>
<p>echo to /index.html.en not supported.<br />
<hr />
<address>Apache/2.0.51 (Unix) mod_ssl/2.0.51 OpenSSL/0.9.7c Server at server7.crucialdns.com Port 80</address>
Connection closed by foreign host.

9. Have apache 2 start up automatically:

For FreeBSD add the following line to /etc/rc.local

/usr/local/apache2/bin/apachectl start

On Red Hat or Fedora 1 or 2:

Copy the apache startup script (apachectl) from the apache directory to the startup directory.

cp /usr/local/apache2/bin/apachectl /etc/init.d/

Add the following 2 lines to /etc/init.d/apachectl (after the #!/bin/sh)

# chkconfig: - 85 15
# description: Apache is a Web server used to serve HTML files and CGI.

Enable apache/httpd to startup automatically:

/sbin/chkconfig --add apachectl


Installing PHP 4.3.8 or 5.0.1 with Apache2

1. Change directory into the PHP source directory (php-4.3.8).

2. Configure PHP using the ./configure command, options are as follows:

Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
run sed PROGRAM on installed program names

SAPI modules:

--with-aolserver=DIR Specify path to the installed AOLserver
--with-apxs[=FILE] Build shared Apache 1.x module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache
build directory, defaults to /usr/local/apache.
--with-mod_charset Enable transfer tables for mod_charset (Rus Apache).
EXPERIMENTAL: Build shared Apache 2.0 module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-apxs2[=FILE] EXPERIMENTAL: Build shared Apache 2.0 module. FILE is the optional
pathname to the Apache apxs tool; defaults to apxs.
--with-caudium[=DIR] Build PHP as a Pike module for use with Caudium
DIR is the Caudium server dir, with the default value
--disable-cli Disable building CLI version of PHP
(this forces --without-pear).
--enable-embed[=TYPE] EXPERIMENTAL: Enable building of embedded SAPI library
TYPE is either 'shared' or 'static'. [TYPE=shared]
--with-isapi[=DIR] Build PHP as an ISAPI module for use with Zeus.
--with-nsapi=DIR Build PHP as NSAPI module for Netscape/iPlanet/SunONE
--with-phttpd=DIR Build PHP as phttpd module
--with-pi3web[=DIR] Build PHP as Pi3Web module
--with-roxen=DIR Build PHP as a Pike module. DIR is the base Roxen
directory, normally /usr/local/roxen/server.
--enable-roxen-zts Build the Roxen module using Zend Thread Safety.
--with-servlet[=DIR] Include servlet support. DIR is the base install
directory for the JSDK. This SAPI prereqs the
java extension must be built as a shared dl.
--with-thttpd=SRCDIR Build PHP as thttpd module
--with-tux=MODULEDIR Build PHP as a TUX module (Linux only)
--with-webjames=SRCDIR Build PHP as a WebJames module (RISC OS only)
--disable-cgi Disable building CGI version of PHP
Enable the security check for internal server
redirects. You should use this if you are
running the CGI version with Apache.
--enable-discard-path If this is enabled, the PHP CGI binary
can safely be placed outside of the
web tree and people will not be able
to circumvent .htaccess security.
--enable-fastcgi If this is enabled, the cgi module will
be built with support for fastcgi also.
If this is disabled, paths such as
/info.php/test?a=b will fail to work.

General settings:

--enable-debug Compile with debugging symbols.
--with-layout=TYPE Sets how installed files will be laid out. Type is
one of PHP (default) or GNU
Sets the path in which to look for php.ini,
defaults to PREFIX/lib
--enable-safe-mode Enable safe mode by default.
--with-exec-dir[=DIR] Only allow executables in DIR when in safe mode
defaults to /usr/local/php/bin
--enable-sigchild Enable PHP's own SIGCHLD handler.
--enable-magic-quotes Enable magic quotes by default.
--disable-rpath Disable passing additional runtime library
search paths
--enable-libgcc Enable explicitly linking against libgcc
--disable-short-tags Disable the short-form <? start tag by default.
--enable-dmalloc Enable dmalloc
--disable-ipv6 Disable IPv6 support
--enable-versioning Export only required symbols.
See INSTALL for more information



NOTE: Not all extensions can be build as 'shared'.

Example: --with-foobar=shared,/usr/local/foobar/

o Builds the foobar extension as shared extension.
o foobar package install prefix is /usr/local/foobar/

--disable-all Disable all extensions enabled by default.

--with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)
--with-zlib[=DIR] Include ZLIB support (requires zlib >= 1.0.9).
--with-zlib-dir=<DIR> Define the location of zlib install directory
--enable-bcmath Enable bc style precision math functions.
--with-bz2[=DIR] Include BZip2 support
--enable-calendar Enable support for calendar conversion
--with-cpdflib[=DIR] Include cpdflib support (requires cpdflib >= 2).
--with-jpeg-dir[=DIR] CPDF: Set the path to libjpeg install prefix.
--with-tiff-dir[=DIR] CPDF: Set the path to libtiff install prefix.
--with-crack[=DIR] Include crack support.
--disable-ctype Disable ctype functions
--with-curl[=DIR] Include CURL support
--with-cyrus[=DIR] Include Cyrus IMAP support
--with-db Include old xDBM support (deprecated, use --enable-dba instead)
--enable-dba Build DBA with builtin modules
--with-gdbm[=DIR] DBA: Include GDBM support
--with-ndbm[=DIR] DBA: Include NDBM support
--with-db4[=DIR] DBA: Include Berkeley DB4 support
--with-db3[=DIR] DBA: Include Berkeley DB3 support
--with-db2[=DIR] DBA: Include Berkeley DB2 support
--with-dbm[=DIR] DBA: Include DBM support
--with-cdb[=DIR] DBA: Include CDB support
--with-inifile DBA: Include INI support
--with-flatfile DBA: Include FlatFile support

--enable-dbase Enable the bundled dbase library
--enable-dbx Enable dbx
--enable-dio Enable direct I/O support
--with-dom[=DIR] Include DOM support (requires libxml >= 2.4.14).
DIR is the libxml install directory.
--with-zlib-dir[=DIR] DOMXML: Set the path to libz install prefix.
--with-dom-xslt[=DIR] DOMXML: Include DOM XSLT support (requires libxslt >= 1.0.18).
DIR is the libxslt install directory.
--with-dom-exslt[=DIR] DOMXML: Include DOM EXSLT support (requires libxslt >= 1.0.18).
DIR is the libexslt install directory.
--enable-exif Enable EXIF (metadata from images) support
--with-fbsql[=DIR] Include FrontBase support. DIR is the FrontBase base directory.
--with-fdftk[=DIR] Include FDF support.
--enable-filepro Enable the bundled read-only filePro support.
--with-fribidi[=DIR] Include FriBidi support (requires FriBidi >= 0.10.4).
--enable-ftp Enable FTP support
--with-gd[=DIR] Include GD support where DIR is GD install prefix.
If DIR is not set, the bundled GD library will be used.
--with-jpeg-dir[=DIR] GD: Set the path to libjpeg install prefix.
--with-png-dir[=DIR] GD: Set the path to libpng install prefix.
--with-zlib-dir[=DIR] GD: Set the path to libz install prefix.
--with-xpm-dir[=DIR] GD: Set the path to libXpm install prefix.
--with-ttf[=DIR] GD: Include FreeType 1.x support
--with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix.
--with-t1lib[=DIR] GD: Include T1lib support.
--enable-gd-native-ttf GD: Enable TrueType string function.
--enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support.
--with-gettext[=DIR] Include GNU gettext support.
--with-gmp[=DIR] Include GNU MP support
--with-hwapi[=DIR] Include official Hyperwave API support
--with-hyperwave Include Hyperwave support
--with-iconv[=DIR] Include iconv support
--with-imap[=DIR] Include IMAP support. DIR is the c-client install prefix.
--with-kerberos[=DIR] IMAP: Include Kerberos support. DIR is the Kerberos install dir.
--with-imap-ssl=<DIR> IMAP: Include SSL support. DIR is the OpenSSL install dir.
--with-informix[=DIR] Include Informix support. DIR is the Informix base
install directory, defaults to nothing.
--with-ingres[=DIR] Include Ingres II support. DIR is the Ingres
base directory (default /ingres)
--with-interbase[=DIR] Include InterBase support. DIR is the InterBase base
install directory, defaults to /usr/interbase
--with-ircg Include IRCG support
--with-ircg-config=PATH IRCG: Path to the ircg-config script
--with-java[=DIR] Include Java support. DIR is the JDK base install directory.
This extension is always built as shared.
--with-ldap[=DIR] Include LDAP support.
--enable-mbstring Enable multibyte string support.
--disable-mbregex MBSTRING: Disable multibyte regex support
--with-libmbfl[=DIR] MBSTRING: Use external libmbfl. DIR is the libmbfl install prefix.
If DIR is not set, the bundled libmbfl will be used.
--with-mcal[=DIR] Include MCAL support.
--with-mcrypt[=DIR] Include mcrypt support.
--with-mcve[=DIR] Include MCVE support. libmcve >= 3.2.2 or libmonetra >= 4.0 required
--with-openssl-dir[=DIR] MCVE: openssl install prefix.
--with-mhash[=DIR] Include mhash support.
Include mime_magic support. FILE is the optional
pathname to the magic.mime file.
--with-ming[=DIR] Include MING support
Include mnoGoSearch support. DIR is the mnoGoSearch
base install directory, defaults to /usr/local/mnogosearch.
--with-msession[=DIR] Include msession support
--with-msql[=DIR] Include mSQL support. DIR is the mSQL base
install directory, defaults to /usr/local/Hughes.
--with-mysql[=DIR] Include MySQL support. DIR is the MySQL base directory.
If unspecified, the bundled MySQL library will be used.
--with-mysql-sock[=DIR] MySQL: Location of the MySQL unix socket pointer.
If unspecified, the default locations are searched.
--with-zlib-dir[=DIR] MySQL: Set the path to libz install prefix.
--with-ncurses[=DIR] Include ncurses support (CLI/CGI only).
--with-oci8[=DIR] Include Oracle-oci8 support. Default DIR is ORACLE_HOME.
--with-adabas[=DIR] Include Adabas D support. DIR is the Adabas base
install directory, defaults to /usr/local.
--with-sapdb[=DIR] Include SAP DB support. DIR is SAP DB base
install directory, defaults to /usr/local.
--with-solid[=DIR] Include Solid support. DIR is the Solid base
install directory, defaults to /usr/local/solid
--with-ibm-db2[=DIR] Include IBM DB2 support. DIR is the DB2 base
install directory, defaults to /home/db2inst1/sqllib
--with-empress[=DIR] Include Empress support. DIR is the Empress base
install directory, defaults to $EMPRESSPATH.
From PHP4, this option only supports Empress Version
8.60 and above
Include Empress Local Access support. DIR is the
Empress base install directory, defaults to
$EMPRESSPATH. From PHP4, this option only supports
Empress Version 8.60 and above.
--with-birdstep[=DIR] Include Birdstep support. DIR is the Birdstep base
install directory, defaults to /usr/local/birdstep.
Include a user defined ODBC support.
The DIR is ODBC install base directory,
which defaults to /usr/local.
Make sure to define CUSTOM_ODBC_LIBS and
have some odbc.h in your include dirs.
E.g., you should define following for
Sybase SQL Anywhere 5.5.00 on QNX, prior to
run configure script:
CUSTOM_ODBC_LIBS="-ldblib -lodbc".
--with-iodbc[=DIR] Include iODBC support. DIR is the iODBC base
install directory, defaults to /usr/local.
--with-esoob[=DIR] Include Easysoft OOB support. DIR is the OOB base
install directory,
defaults to /usr/local/easysoft/oob/client.
--with-unixODBC[=DIR] Include unixODBC support. DIR is the unixODBC base
install directory, defaults to /usr/local.
--with-dbmaker[=DIR] Include DBMaker support. DIR is the DBMaker base
install directory, defaults to where the latest
version of DBMaker is installed (such as
--with-oracle[=DIR] Include Oracle-oci7 support. Default DIR is ORACLE_HOME.
--disable-overload Disable user-space object overloading support.
--with-ovrimos[=DIR] Include Ovrimos SQL Server support. DIR is the
Ovrimos libsqlcli install directory.
--enable-pcntl Enable experimental pcntl support (CLI/CGI only)
--without-pcre-regex Do not include Perl Compatible Regular Expressions
support. Use --with-pcre-regex=DIR to specify DIR
where PCRE's include and library files are located,
if not using bundled library.
--with-pdflib[=DIR] Include PDFlib support.
--with-jpeg-dir[=DIR] PDFLIB: define libjpeg install directory.
(OPTIONAL for PDFlib v4)
--with-png-dir[=DIR] PDFLIB: define libpng install directory.
(OPTIONAL for PDFlib v4)
--with-zlib-dir[=DIR] PDFLIB: define libz install directory.
(OPTIONAL for PDFlib v4)
--with-tiff-dir[=DIR] PDFLIB: define libtiff install directory.
(OPTIONAL for PDFlib v4)
--with-pfpro[=DIR] Include Verisign Payflow Pro support.
--with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL
base install directory, defaults to /usr/local/pgsql.
--disable-posix Disable POSIX-like functions
--with-pspell[=DIR] Include PSPELL support.
GNU Aspell version 0.50.0 or higher required.
--with-qtdom Include QtDOM support (requires Qt >= 2.2.0).
--with-libedit[=DIR] Include libedit readline replacement (CLI/CGI only).
--with-readline[=DIR] Include readline support (CLI/CGI only).
--with-recode[=DIR] Include recode support.
--disable-session Disable session support
--with-mm[=DIR] Include mm support for session storage
--enable-shmop Enable shmop support
--with-snmp[=DIR] Include SNMP support.
--with-openssl-dir[=DIR] SNMP: openssl install prefix.
--enable-ucd-snmp-hack Enable UCD SNMP hack
--enable-sockets Enable sockets support
--with-regex=TYPE regex library type: system, apache, php. Default: php
WARNING: Do NOT use unless you know what you are doing!
--with-swf[=DIR] Include swf support
--with-sybase[=DIR] Include Sybase-DB support. DIR is the Sybase home
directory, defaults to /home/sybase.
--with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home
directory. Defaults to /home/sybase.
--enable-sysvmsg Enable sysvmsg support
--enable-sysvsem Enable System V semaphore support.
--enable-sysvshm Enable the System V shared memory support.
--disable-tokenizer Disable tokenizer support
--enable-wddx Enable WDDX support.
--disable-xml Disable XML support using bundled expat lib
--with-expat-dir=<DIR> XML: external libexpat install dir
--with-xmlrpc[=DIR] Include XMLRPC-EPI support.
--with-expat-dir=<DIR> XMLRPC-EPI: libexpat dir for XMLRPC-EPI.
--with-iconv-dir=<DIR> XMLRPC-EPI: iconv dir for XMLRPC-EPI.
--enable-xslt Enable xslt support.
--with-xslt-sablot=<DIR> XSLT: Enable the sablotron backend.
--with-expat-dir=<DIR> XSLT: libexpat dir for Sablotron.
--with-iconv-dir=<DIR> XSLT: iconv dir for Sablotron.
--with-sablot-js=<DIR> XSLT: enable JavaScript support for Sablotron.
--with-yaz[=DIR] Include YAZ support (ANSI/NISO Z39.50).
DIR is the YAZ bin install directory.
--enable-yp Include YP support.
--with-zip[=DIR] Include ZIP support (requires zziplib >= 0.10.6).


--with-pear=DIR Install PEAR in DIR (default PREFIX/lib/php)
--without-pear Do not install PEAR


This will most likely break your build
If building zend_execute.lo fails, try this switch.
--enable-memory-limit Compile with memory limit support.
--enable-zend-multibyte Compile with zend multibyte support.


Use GNU Pth.
--with-tsrm-st Use SGI's State Threads
--with-tsrm-pthreads Use POSIX threads (default)


--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS] optimize for fast installation [default=yes]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--disable-libtool-lock avoid locking (might break parallel builds)
--with-pic try to use only PIC/non-PIC objects [default=use both]


To compile PHP in with the apache2 use the following settings.

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --prefix=/usr/local/apache2/php --with-config-file-path=/usr/local/apache2/php --enable-force-cgi-redirect --disable-cgi

--with-apxs2 - this compiles the PHP module for apache 2

--with-mysql - this enables mysql connectivity for PHP 4

--prefix - defines the location PHP will be installed in

--with-config-file-path - defines where the PHP 4.3.8 config files will be stored

---enable-force-cgi-redirect - enables security check for internal server redirects

--disable-cgi - makes sure php does not run under CGI

3. Build PHP using the 'make' command inside the PHP source directory


4. Install the PHP application files to their specified locations.

make install

5. If /usr/local/apache2/modules/libphp4.so does not exist then run the following command:

cp -p .libs/libphp4.so /usr/local/apache2/modules

6. Copy the default configuration file to the PHP config directory:

cp -p php.ini-recommended /usr/local/apache2/php/php.ini

7. Open the apache2 logfile and make sure that the following lines exist:

LoadModule php4_module modules/libphp4.so

DirectoryIndex index.html index.php

AddType application/x-httpd-php php

AddType application/x-httpd-php-source phps
^ This one adds colouring to PHP syntax, not required

If these do not exist in your apache config files (/usr/local/apache2/conf/httpd.conf) then add then so as to allow PHP to function correctly.

8. Restart apache:

/usr/local/apache2/bin/apachectl restart

9. Check that PHP and apache are running, create the following directory in your html directory:


<?php echo phpinfo(); ?>

10. Visit youraddress.com to check if PHP info is displayed.


PHP 5 and Apache 2 installation coming soon!

1. Download PHP5.0.1: wget http://www.php.net/get/php-5.0.1.tar.gz/from/www.php.net/mirror

*Note: If you are having problems getting php-5.0.1 working then try downloading the latest snapshot from: http://snaps.php.net/php5-latest.tar.gz

2. Untar and un gzip: tar zxvf php-5.0.1.tar.gz

3. cd php-5.0.1/

4. check out the install options using ./configure --help
The next step was the configuration we used to install apache on a standard FreeBSD installation.

5. ./configure --prefix=/usr/local/apache2/php5 --with-apxs2=/usr/local/apache2bin/apxs --disable-cgi --enable-force-cgi-redirect --disable-libxml --libexecdir=/usr/local/apache2/modules --exec-prefix=/usr/local/apache2/php5 --with-config-file-path=/usr/local/apache2/php5

*Note that we have used apache/php5 for the installation directory. We are going to parse all .php5 with PHP 5 and all .php files with PHP 4.

5. make

6. make install

7. Open up your apache config file

vi /usr/local/apache2/conf/httpd.conf

Add the following lines of code:

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php php
AddType application/x-httpd-php-source phps

8. Restart apache 2:

/usr/local/apache2/bin/apachectl restart

9. Create a test PHP file showing phpinfo

vi /usr/local/apache2/htdocs/phpinfo.php

<?php phpinfo(); ?>

10. Visit site to check you are receiving your phpinfo page:



If you have problems during your Apache 2 and PHP 5 or 4 installation. Try removing the source directory, untaring it again, and trying a different set of configuration options.

Similar Articles : How to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source, How to install ffmpeg on CentOS or Redhat Enteprirse Linux the easy way (Using RPMs/Yum) , Installing Pico on FreeBSD, Turck MMCache for PHP, Apache 2 Install and Upgrade Guide, lingerd - Setup and Installation, Howto mod_rewrite with Apache, Getting started with SSH Tutorial, How to install PRM (Process Resource Monitor), How to install ionCube loader, Apache Log Files Explained, Server Loads Explained, Guide to .htaccess tutorial and tips, Optimize and Tweak High-Traffic Servers, Common SSH Commands - Linux Shell Commands, Upgrade Guide From Red Hat 7.3 to 9.0, Changing Web Hosts? Step-By-Step Guide, Customizing PHP Safe Mode, Apache 2 PHP 4 and 5 (mod_php) on Linux - Apache2 PHP4 PHP5 Installation, Fantastico Error: enc_restrictions.inc.php is protected by SourceGuardian and requires file ixed.lin.4.X.X.pxp, 4.3.7.pxp, 4.3.8.pxp, 4.3.9.pxp error, How to Copy Files Across a Network/Internet in UNIX/LINUX (Redhat, Debian, FreeBSD, etc) - scp tar rsync, Fixing rndc error in WHM/cPanel: rnd: connection failed: connection refused, wget - how to use tuturial, cPanel Awstats Fix - Stoped Logging on single domain, How to Install Zend Optimizer/Encoder on cPanel/WHM, Upgrading CentOS 3.3 to 3.4 using yum, Redhat 7.3, 8.0, and 9.0 upgrade to CentOS 3 using yum (Red hat), Tutorial/HOW-TO: Kernel 2.6 Compilation with Grsecurity (grsec) - 2.6.5, 2.6.7, 2.6.8, 2.8.1, 2.6.9, 2.6.10, , Repairing a mySQL Database/Table - How to restore/repair/recover, Flood Protection/DoS/DDoS Apache 1.3 and 2.0 - mod_dosevasive (Avoiding Denial of Service Attacks)


Quick Links: Debian Dedicated Servers, Direct Deposit Hosting, Unmetered Dedicated Servers, Virtual Dedicated Servers, Windows Server Management, High Traffic Web Hosting - Load Balanced Clusters