If you are compiling from the PHP source tarball, follow the
instructions in the INSTALL file found inside
the PHP distribution file. A tarball is a compressed
tar file. tar stands for
tape archive, but these days it has little to do with tapes. It is
simply a way to lump multiple files and directories into a single
file for distribution. Normally tarballs have the
.tar.gz extension to indicate a
tar file compressed with
gzip. To untar a tarball, use:
tar zxvf foo.tar.gz
On Windows, many utilities (including WinZip) understand tarballs.
If you are installing from a precompiled binary package such as an
rpm file, most of the work should be done for
you. But doublecheck that the Apache configuration described below is
correct.
When you are using PHP as an Apache module, PHP processing is
triggered by a special MIME type. This is defined in the Apache
configuration file with a line similar to:
AddType application/x-httpd-php .php
This line tells Apache to treat all files that end with the
.php extension as PHP files, which means that
any file with that extension is parsed for PHP tags. The actual
extension is completely arbitrary and you are free to change it to
whatever you wish to use.
If you are running PHP as a dynamic shared object (DSO) module, you
also need this line in your Apache configuration file:
LoadModule php4_module modules/libphp4.so
Note that in many default httpd.conf files you
will find AddModule lines. These really aren't
necessary. They are only needed if you have a ClearModuleList
directive somewhere in your httpd.conf file. I
would suggest simply deleting the ClearModuleList directive and
deleting all your AddModule lines. The idea behind
ClearModuleList/AddModule is to make it possible to reorder already
loaded modules in case module order is an issue. With most modules,
the order that they are loaded—which governs the order they are
called—is not important. And further, most binary distributions
of Apache ship with most modules compiled as dynamically loadable
modules, which means that if order is an issue for some reason, you
can simply change the order of the LoadModule calls to fix it.
Don't forget to restart your server after making
changes to your httpd.conf file. Once the server
is restarted, you can check to see if PHP is working by creating a
file in your document root named info.php
containing the single line:
<?php phpinfo( )?>
Load this up in your browser using
http://your.domain.com/info.php. You should see
all sorts of information about PHP. If you don't see
anything, try selecting "View
Source" in your browser. If you see the
phpinfo( ) line, you probably forgot (or mistyped)
the AddType line in your httpd.conf file. If the
browser tries to download the file instead, it means that the AddType
is there, but the PHP module is not being triggered—perhaps
because you forgot the LoadModule line.
Once you have verified that PHP is working, have a look at the PHP
initialization file called php.ini. The
phpinfo( ) page will tell you where PHP is
expecting to find it. PHP functions fine without this file, but with
all the default settings. If you want to change the defaults, or
perhaps more importantly, you want to be immune from any changes to
the defaults when you upgrade, you should create a
php.ini file. The source distribution of PHP
comes with a php.ini-dist file that you can
rename and copy into the location specified in the phpinfo(
) output. The php.ini file itself is
well-commented and self-explanatory for the most part.