Installing PHP (Under Linux) - Page 7
January 3, 2002
As mentioned above, PHP is not really a program in and of itself. Instead, it's a plug-in module for your Web server (probably Apache). There are actually three ways to install the PHP plug-in for Apache:
The first option is the easiest to install and set up, but it requires Apache to launch PHP as a program on your computer every time a PHP page is requested. This can really slow down the response time of your Web server, especially if more than one request needs to be processed at a time.
The second and third options are almost identical in terms of performance, but since you‘re likely to have Apache installed already, you'd probably prefer to avoid having to download, recompile, and reinstall it from scratch. For this reason, we'll use the third option.
To start, download the PHP Source Code package from http://www.php.net/ (or one of its mirrors listed at http://www.php.net/mirrors.php). At the time of this writing, PHP 4.x has become well-established as the version of choice; however, some old servers still use PHP 3.x (usually because nobody has bothered to update it). I'll be covering the installation of PHP4 here, so be aware that if you still work with PHP3 there may be some minor differences.
The file you downloaded should be called
To install PHP as a loadable Apache module, you'll need the
For the rest of the install procedure, you'll need to be logged
in as the
The next step is to configure the PHP installation program by telling it which options you want to enable, and where it should find the programs it needs to know about (like Apache and MySQL). Unless you know exactly what you're doing, simply type the command like this (all on one line):
Again, check for any error messages and install any files it identifies as missing. On Mandrake 8.0, for example, it complained that the 'lex' command wasn't found. I searched for 'lex' in the Mandrake package list and it came up with 'flex', which it described as a program for matching patterns of text used in many programs' build processes. Once that was installed, the configuration process went without a hitch. After you watch several screens of tests scroll by, you'll be returned to the command prompt. The following two commands will compile and then install PHP. Take a coffee break: this will take some time.
PHP is now installed in
You may now delete the directory from which you compiled PHP - it's no longer needed.
We'll worry about fine-tuning
Find the new, uncommented line (no # at the start of the line),
not the old line that you may have commented out earlier. It may
not appear along with the other
PHP will probably run correctly without this change, but on older
versions of RedHat, Apache won't be able to find the
Next, look for the line that begins with
Finally, go right to the bottom of the file (again, this should
That should do it! Save your changes and restart your Apache server. If all things go to plan, Apache should start up without any error messages. If you run into any trouble, the helpful folks in the SitePoint.com Forums (myself included) will be happy to help.