Here are the steps to installing PHP:
-
Steps 1 to 7 of the Apache installation instructions should be completed.
-
Get the latest version of PHP from
http://www.php.net/downloads.php
. Download the "Complete Source Code" version into the /tmp directory. -
Choose an installation directory. If the Apache installation was begun in /usr/local/, the same location can also be used for PHP. We assume in the following steps that the base directory of the Apache installation and PHP installation are the same. Move the PHP source code file to the base directory of the desired installation. Assuming this is /usr/local/ and, assuming the distribution downloaded is PHP 4.0.6 and it was downloaded into the /tmp directory, the command is:
% mv /tmp/php-4.0.6.tar.gz /usr/local/
After moving the distribution to the desired location, change directory to that location using:
% cd /usr/local
-
Uncompress the package in the new installation directory by running:
% gzip -d php-<
version_number
>.tar.gzIf the version downloaded is PHP 4.0.6, the command is:
% gzip -d php-4.0.6.tar.gz
-
Un-tar the distribution by running:
% tar xvf php-<
version_number
>.tarA list of files extracted is displayed.
If the version downloaded is PHP 4.0.6, the command is:
% tar xvf php-4.0.6.tar
-
Change directory to the PHP installation:
% cd php-<
version_number
>If the version is PHP 4.0.6, type:
% cd php-4.0.6
-
Configure the PHP installation by running the configure script. This detects the available Linux tools, the installation environment, adds MySQL support, and prepares for Apache integration. It assumes that MySQL has been installed previously in the directory /usr/local/mysql:
% ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_<
vers
>If Apache 1.3.20 is being used, type:
% ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.20
-
Compile the PHP scripting engine by running:
% make
-
Now that the PHP scripting engine is built, install the PHP engine using:
% make install
-
The PHP installation is almost complete. Now copy across the default PHP configuration file to the default location, This file,php.ini, contains the settings that control the behavior of PHP and includes, for example, how variables are initialized, how sessions are managed, and what scripting tags can be used. The command to copy the file is:
% cp php.ini-dist /usr/local/lib/php.ini
-
Change directory to the Apache installation:
% cd ../apache_<
version_number
>If Apache 1.3.20 is being installed, type:
% cd ../apache_1.3.20
-
The initial configuration of the PHP scripting engine module is now complete. Return to Step 8 of the Apache installation procedure and complete the installation of Apache, which includes a test of the PHP module.