Building PHP 4.3.8 under Mandrake 9.1
I took the following notes after successfully installing PHP 4.3.8 on my Mandrake 9.1. I hope that these notes might be helpful to others.
Author: Mario Graziosi, mgnospam@fgasoftware.com
I took the following notes after successfully installing PHP 4.3.8 on my Mandrake 9.1. I hope that these notes might be helpful to others. Briefly, follow these steps:
- Download PHP from http://www.php.net and untar it
- Install Apache2 Develpment from Mandrake CD,
- Issue the configure command for PHP,
- Issue the make command,
- Issue the make install command,
- Any comments?
You'll need to have root privileges. For details of each step, please, read on.
Download PHP and untar it
This is quite simple. You can download the PHP tar file from www.php.net either in bz2 or gz format. Once downloaded (e.g. in bz2 format), copy it to your home dir (or any other dir) and unpack it. Supposing the file php-4.3.8.tar.bz2 is in your home dir, issue the following commands:
cd ~
bzip2 -d php-4.3.8.tar.bz2
tar xvf php-4.3.8.tar
After issuing the above commands you'll find a directory named php-4.3.8 under your home dir (if you wish, you can get rid of the php-4.3.8.tar file).
Install Apache2 Development from Mandrake CD
To be able to build PHP you need to install Apache2 Devel package which is needed for apxs2 (Mandrake 9.1 comes with Apache 2.x, not Apache 1.3.x). You can use Mandrake RPM manager to install it. Go to RpmDrake and select apache2-devel-2.0.44-11mdk for installation. Accept any dependencies and proceed with installation.
You will also need lex (and maybe YACC). Thus, if not yet installed, you should also install, at this time, bison and flex.
Issue the "configure" command for PHP
Now you're ready to configure PHP issuing the configure command, which will tailor PHP config files.
To be sure to have PHP configured the same way as currently installed, you should build a simple .php file which issues a phpinfo() command. For example, file phpinfo.php contents might be a single line:
<?php phpinfo(); ?>
Then, copy this file under your www/html dir (or any other reachable directory) and view it (e.g. http://www.myhost.com/phpinfo.php). The page will show you the currently installed release of PHP and several useful info. Right at the beginning of the page you should find the Configure Command text. For example, in my case the command I got from phpinfo() was:
'./configure' '--prefix=/usr' '--libdir=/usr/lib' '--enable-discard-path' '--disable-force-cgi-redirect' '--enable-shared' '--disable-static' '--disable-debug' '--disable-rpath' '--enable-pic' '--enable-inline-optimization' '--enable-memory-limit' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php' '--with-pear=/usr/share/pear' '--enable-magic-quotes' '--enable-debugger' '--enable-track-vars' '--with-exec-dir=/usr/bin' '--with-versioning' '--with-mod_charset' '--with-regex=php' '--enable-track-vars' '--enable-trans-sid' '--enable-safe-mode' '--enable-ctype' '--enable-ftp' '--with-gettext=/usr' '--enable-posix' '--enable-session' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--with-openssl=/usr' '--without-kerberos' '--with-ttf' '--with-freetype-dir=/usr' '--with-zlib=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr'
Cut & paste the text from the Configure Command and get ready to add some options to it. Add the '--with-apxs2=/usr/sbin/apxs2' option to the above command, achieving something like:
'./configure' '--with-apxs2=/usr/sbin/apxs2' '--prefix=/usr' '--libdir=/usr/lib' '--enable-discard-path' '--disable-force-cgi-redirect' '--enable-shared' '--disable-static' '--disable-debug' '--disable-rpath' '--enable-pic' '--enable-inline-optimization' '--enable-memory-limit' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php' '--with-pear=/usr/share/pear' '--enable-magic-quotes' '--enable-debugger' '--enable-track-vars' '--with-exec-dir=/usr/bin' '--with-versioning' '--with-mod_charset' '--with-regex=php' '--enable-track-vars' '--enable-trans-sid' '--enable-safe-mode' '--enable-ctype' '--enable-ftp' '--with-gettext=/usr' '--enable-posix' '--enable-session' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--with-openssl=/usr' '--without-kerberos' '--with-ttf' '--with-freetype-dir=/usr' '--with-zlib=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr'
If you wish, you may also add bz2 support (--with-bz2) and calendar support (--enable-calendar), since these come enabled with Mandrake 9.1. You may find a full list of configure options at http://www.phpbuilder.com/.
Running as root,from within the ~/php-4.3.8 directory, issue the configure command you just prepared. If you get and error "lex: command not found" you'll need to install lex (flex) and, perhaps, bison (for YACC). After issuing the command you'll see several info messages and, at the end, a "Thank you for using PHP" message.
Issue the "make" command
Once done, you're ready to really build your own PHP. At the command line (as Super User) issue the make command (as always, from within the ~/php-4.3.8 directory):
make
This will take a while (several minutes), depending on the speed of your computer. At the end you'll might get the following message: "the use of `tempnam' is dangerous, better use 'mkstemp'". Simply ignore it.
Issue the "make install" command
Until now, you simply compiled your own version of PHP, but you did not yet installed it. You are now ready to install it. However, before installing it, I recommend that you make a copy of the original phpinfo page (remember, the one from which you did cut & paste the configure command). Save the original phpinfo page because it might be useful if you need later on to compare possible differences between the two versions.
To install the new version of php, issue the make install command:
make install
This will take a short time and will, in fact, publish the new version. You should then restart apache to effectively see the effect. A new call to phpinfo() should show the new version.
Any Comments?
I hope that you found this document helpful. Please, beware that this is a "Linux newbie doc" and thus some info might be imprecise. If you believe that I omitted some important info, please let me know (mgraziosi@fgasoftware.com). Any suggestion is welcome, even in non-english language (I can read and reply in italian and portuguese, as alternative languages).