Fast2Host Logo

PHP

How to recompile PHP for linux to include extra

So you realized you'll need to install mcrypt libraries in order to operate your billing package eh? In addition to installing mcrypt, you'll also have to re-compile php in order to include the support for mcrypt. This has worked for me numerous times without anything breaking or failing to operate. Obviously, I'm not responsible for whether you try this or not. A healthy and current backup is always a good idea before diving into the world of re-compiling software packages.

FYI - My machine stats are:
RH Linux 7.3 kernel 2.4.18-27.7.x
Cpanel/WHM
Apache 1.3.27
PHP 4.3.1

Ready? Here's how you do it.

As root:

1) Install libmcrypt (2.5.x or better) http://mcrypt.hellug.gr/lib/index.html
-download and uncompress: tar z -xvf xxx.tar.gz
-cd into libmcrypt dir and type: ./configure
-when configure is done type: make
-when make is done type: make install

2) Add the library dir to /etc/ld.so.conf
-edit /etc/ld.so.conf and add: /usr/local/lib
-save file and then type the command: ldconfig

3) Update/Install Mhash (0.8.15 or newer) http://mhash.sourceforge.net/
-download and uncompress: tar z -xvf xxx.tar.gz
-cd into libmcrypt dir and type: ./configure
-when configure is done type: make
-when make is done type: make install
-when make install is done type: ldconfig

4) Install latest version of mcrypt (2.6.x or better) http://mcrypt.hellug.gr/mcrypt/index.html
-download and uncompress: tar z -xvf xxx.tar.gz
-cd into mcrypt dir and type: ./configure
-when configure is done type: make
-when make is done type: make install
-when make install is done type: ldconfig

5) Take note of your current php info
-create a file somewhere on your webserver called phpinfo.php
-edit the file and add the single line:
-make sure a normal user owns the file (not root - ie: chown user.user phpinfo.php)
-issue the command: chmod 755 phpinfo.php
-open the file in a web browser ie: www.yourserver.com/phpinfo.php
-copy the contents of "Configure Command" to a text file somewhere.
-It will look something like this (probably all on 1 line - leave it on 1 line):
'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath'
'--enable-calendar' '--enable-ftp' '--enable-magic-quotes' '--with-mysql' '--with-pear'
'--enable-sockets' '--enable-track-vars' '--enable-versioning' '--with-zlib'
-edit the command to remove all the ' ' marks so it looks like this:
./configure --with-apxs=/usr/local/apache/bin/apxs --with-xml --enable-bcmath --enable-calendar
--enable-ftp --enable-magic-quotes --with-mysql --with-pear --enable-sockets --enable-track-vars
--enable-versioning --with-zlib
-at the end, add the following (assuming mcrypt is actually found in /usr/local/bin/mcrypt):
--with-mcrypt=/usr/local/bin/mcrypt
-save the text file.

6) Go into your php source directory: /home/cpapachebuild/buildapache/php-4.3.1/
-type: make clean
-type: rm config.cache (yes, remove that file)
-issue your command you saved in the text file. Something like this:
./configure --with-apxs=/usr/local/apache/bin/apxs --with-xml --enable-bcmath --enable-calendar
--enable-ftp --enable-magic-quotes --with-mysql --with-pear --enable-sockets --enable-track-vars
--enable-versioning --with-zlib --with-mcrypt=/usr/local/bin/mcrypt
-when that is done, type: make
-when that is done, type: make test (most tests will fail... about 50%-60% or so)
-when that is done, type make install

7) Restart Apache
-issue the command: service httpd restart
-go back to your phpinfo.php page and check to see that --with-mcrypt now shows up in the "Configure Command"

 



Maintain peace of mind with UK based support

Email any time or call 01480 26 00 00 014 80 26 00 00