Howto install php4 & php5 on Apache2

Menù di navigazione
  • Home
  • Contacts
HOME | Index |

Howto install php4 & php5 on Apache2

Yes, we had to do it.... AGAIN!

As a professional team of programmers, we aren't free from PHP4... And we had to install it on a server running apache2 and php5.

The method is simple. First create a directory:

mkdir /home/php4

Then download php source code and untar it. Cd to the obtained source directory.

Then you have to modify some files: to know their names we run grep:

grep -ir application/x-httpd-php ./

We obtain a list of files to modify:

./main/php.h:#define PHP_MIME_TYPE "application/x-httpd-php"
./sapi/apache2handler/README:        AddType application/x-httpd-php .php
./sapi/apache2handler/README:        AddType application/x-httpd-php-source .phps
./sapi/apache2handler/sapi_apache2.c:#define PHP_MAGIC_TYPE "application/x-httpd-php"
./sapi/apache2handler/sapi_apache2.c:#define PHP_SOURCE_MAGIC_TYPE "application/x-httpd-php-source"
./sapi/apache/mod_php4.c:       {"application/x-httpd-php", send_parsed_php},
./sapi/apache/mod_php4.c:       {"application/x-httpd-php-source", send_parsed_php_source},
./sapi/apache2filter/README:        AddType application/x-httpd-php .php
./sapi/apache2filter/README:        AddType application/x-httpd-php-source .phps
./sapi/apache2filter/sapi_apache2.c:                    if (strncmp(ctx->r->handler, "application/x-httpd-php-source", sizeof("application/x-httpd-php-source"))) {
./sapi/apache2filter/sapi_apache2.c:    int content_type_len = strlen("application/x-httpd-php");
./sapi/apache2filter/sapi_apache2.c:    if (r->content_type && !strncmp(r->content_type, "application/x-httpd-php", content_type_len-1)) {

Using vi we can substitute the string application/x-httpd-php with application/x-httpd-erwphp:

vi ./main/php.h
vi ./sapi/apache2handler/sapi_apache2.c
vi ./sapi/apache/mod_php4.c
vi ./sapi/apache2filter/sapi_apache2.c

Then you can run configure:


./configure \
--prefix=/home/php4 \
--exec-prefix=/home/php4 \
--with-config-file-path=/home/php4/etc \
--with-mysql \
--with-apxs2=/usr/sbin/apxs \
--with-exec-dir=/home/php4/libexec \
--enable-inline-optimization \
--disable-debug \
--enable-bcmath \
--enable-calendar \
--enable-ctype \
--enable-dbase \
--enable-discard-path \
--enable-exif \
--enable-filepro \
--enable-ftp \
--enable-gd-imgstrttf \
--enable-gd-native-ttf \
--with-ttf \
--enable-magic-quotes \
--enable-memory-limit \
--enable-shmop \
--enable-sigchild \
--enable-sysvsem \
--enable-sysvshm \
--enable-track-vars \
--enable-trans-sid \
--enable-wddx \
--enable-yp \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--without-xpm \
--with-zlib=yes \
--with-dom \
--with-gd \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--enable-sockets \
--enable-mbstring=all \
--with-curl \
--enable-mbregex \
--enable-zend-multibyte \
--enable-exif \
--enable-pcntl \
--with-mime-magic \
--with-bz2 \
--with-iconv

When configure stops running you can do

make
make install

This will produce a PHP4 apache2 module perfectly running.

You will have also all PHP related bins into /home/php4/bin

Now you have to link the brand new installation to your apache.

First remove the LoadModule directive from httpd.conf (is placed there by the installer...)

vi /etc/httpd/conf/httpd.conf

Look for "LoadModule php4_module" and remove the entire line.

Open the php configuration apache file:

vi /etc/httpd/conf.d/php.conf

Add these lines

LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-erwphp .php4

Now restart apache and enjoy your PHP4 extensions! (it works for files with .php4 extension....)

Labs
  • CentOS + BlueQuartz
  • Installing Spamassassin ClamAv and Mailscanner on Bluequartz
  • SARE Rules & RulesDuJour
  • Installing MRTG
  • Mass Change IP
  • CCED problems
  • Deleting old logfiles
  • POP3 problems
  • Recalculate Quotas
  • How to block an IP address
  • NAMED and DNS
  • PHP
  • Enabling safe mode per-directory
  • Howto install php4 & php5 on Apache2
  • Linux
  • Automating Mysql backups
  • Restoring MySQL dumps
  • Replacing Text In Files
  • Firefox and flash on x86_64
  • Find user's files
  • Lines of code
  • Vsftp with virtual users
  • MSN
  • RandomCase

Home | Contacts | E.R.WEB Official Site