6. mod_php and its prerequisites

6.1. What is mod_php

 

PHP is a server-side, cross-platform, HTML embedded scripting language.

In the beginning it was just a simple guestbook-processor, and it was growing and growing Since Version 3 it is really powerful Webdevelopment-language

 
--www.php.net 

Since Version 4 PHP capable and robust enough for enterprise webapplications. It is powerful, supports almost all important databases natively, and other through ODBC (Open DataBase Connectivity). It a few times faster than ASP on Windows Systems on the same Hardware.

There are other extensions available like APC (Alternative PHP Cache), which speed up processing about 50-400% (depends on the php-code you wrote)

6.2. Prerequisites

Depending on your needs there are some software to install first. One already installed Software according this document is MySQL, because its needed by mod_auth_mysql.

6.2.3. Building and installing

cd /usr/local

tar -xvfz imap.tar.Z

cd imap

make slx SSLTYPE=nopwd (1)

(1)
With the parameter SSLTYPE=unix you define if you need SSL support or not. Omitting means no SSL support.

TipFilename to download
 

imap.tar.Z is usually a symlink to the latest release, today its linked to imap-2001a.tar.Z

6.3. Building and installing PHP4

cd /usr/local

tar -xvzf php-4.3.0.tar.gz

cd php-4.3.0

export LDFLAGS=-lstdc++

./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-pgsql=/usr/local/pgsql \
--enable-track-vars \
--with-openssl=/usr/local/ssl \
--with-imap=/usr/local/imap \
--with-gd --with-ldap \
--enable-ftp \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-pdflib=/usr/local \
--with-gettext \
--with-mm=/usr/local/mm-1.1.3 \
--with-jpeg-dir=/usr/lib \
--with-zlib-dir=/usr/local \
--enable-wddx \
--with-mcrypt \
--with-mhash \
--with-mcal=/usr \
--enable-exif \
--enable-xslt \
--with-xslt-sablot=/usr/local \
--with-dom \
--with-dom-xslt \

Edit the Makefile and add -lstdc++ to the variable EXTRA_LIBS. This is currently only needed, when using Sablotron version 0.9.7

make
make install

After installing your httpd.conf is modified by axps. It should now look as follows:

<IfDefine SSL>
LoadModule ssl_module         libexec/libssl.so
LoadModule php4_module        libexec/libphp4.so
</IfDefine>

If you compiled Apache with mod_ssl then the php-module will only be loaded when staring Apache with ssl (apachectl startssl). If you will start Apache without ssl support (but compiled like described in this document) you need to change this:

<IfDefine SSL>
LoadModule ssl_module         libexec/libssl.so
</IfDefine>
LoadModule php4_module        libexec/libphp4.so

Copy the sample php.ini-dist to /usr/local/lib/php.ini

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

uncomment (remove the # at begin of line) the following lines in /usr/local/apache/conf/httpd.conf

Apache 1.3.27 default httpd.conf does lack of this entries. You have to add them instead of uncommenting

AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php3

# If you want to display PHP source 

AddType application/x-httpd-php-source .phps (1)

(1)
This line is only needed if you like to display sourcecodes in the browser. The fileextension of such files should be phps. /para>

Tipregister_globals
 

Since PHP Version 4.2.1, »register_globals« are set OFF. This can bring you in problems running PHP-Code not using the $HTTP_GET_VARS methods. To enable register_globals edit the following line in your /usr/local/lib/php.ini:

register_globals = On

Please be sure, if you write new software, to use the new methods. Support of old methods will be dropped sooner or later

Restart Apache by issuing the following command:

/usr/local/apache/bin/apachectl restart