HomeApache Page 6 - Getting Started with Apache 2.0, Part 1
PHP 5.0.3 with Apache 2.0.52 - Apache
In this first article in a three-part series, Harish Kamath helps you download and configure the Apache Web server. If you've wanted to use PHP with Apache, look no further; that part of the setup is also covered here.
At the onset, I promised that I would demonstrate how to configure PHP 5.0 with Apache 2.0 - and I always keep my promises!
Before I continue any further, I must highlight a warning by "The PHP Group" that the combination of PHP and Apache 2.0 is not recommended in a production environment. You can read the reasons behind this "stern" warning in the official PHP FAQ: http://www.php.net/manual/en/faq.installation.php# faq.installation.apache2
If you are still looking to get your hands dirty with this combination, despite all my warnings and caveats - welcome aboard.
This is where you must run a quick check on your existing Apache installation: did you build it to load modules dynamically by specifying the "--enable-so" option? If not, quickly fire the following commands to get moving:
Next, you'll need to download the source code for the latest version of PHP (currently 5.0.3) from the following URL: http://www.php.net/downloads.php.
Unzip the PHP 5 source code on your server and run the "configure" command as shown below.
Note that I have not enabled many PHP libraries in the above "configure" command. If you plan to use them extensively, it would be wise to review the options that are listed at this URL: http://in.php.net/manual/en/configure.php, before moving ahead. Note that these options have been listed for PHP 4 compilation; however, they should work for PHP 5 also.
Now, you'll have to run the "make" and "make install" commands.
$ make
$ make install
Ready to rock-n-roll? Not so fast. There is still one last bit of configuration of the Apache Web server that enables it to identify PHP files and pass them to the PHP module for interpretation. This is only possible by editing the ubiquitous "httpd.conf" Apache configuration file in your favorite text editor and adding the following line:
AddType application/x-httpd-php .php
Now, you can re-start Apache using the "apachectl" script and load the following "phpinfo.php" script (saved in the root folder of the Web server) in a browser:
<?php
phpinfo();
?>
Instead of getting a screen full of cryptic error messages or warnings, if you get the following screen, rest assured that you have successfully installed PHP 5.0 with Apache 2.0.