PHP

Installing PHP

The instructions here are for installing PHP4. PHP is bundled with most Linux installations. However, we assume PHP isn't installed or, if it is installed, that a newer version is required to replace the existing installation. If Apache is being reinstalled, PHP needs to be reinstalled also.

Here are the steps to installing PHP:

  1. Steps 1 to 7 of the Apache installation instructions should be completed.

  2. Get the latest version of PHP from http://www.php.net/downloads.php . Download the "Complete Source Code" version into the /tmp directory.

  3. 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
    
  4. Uncompress the package in the new installation directory by running:

    % gzip -d php-<version_number>.tar.gz
    

    If the version downloaded is PHP 4.0.6, the command is:

    % gzip -d php-4.0.6.tar.gz
    
  5. Un-tar the distribution by running:

    % tar xvf php-<version_number>.tar
    

    A 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
    
  6. Change directory to the PHP installation:

    % cd php-<version_number>
    

    If the version is PHP 4.0.6, type:

    % cd php-4.0.6
    
  7. 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
    
  8. Compile the PHP scripting engine by running:

    % make
    
  9. Now that the PHP scripting engine is built, install the PHP engine using:

    % make install
    
  10. 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
    
  11. Change directory to the Apache installation:

    % cd ../apache_<version_number>
    

    If Apache 1.3.20 is being installed, type:

    % cd ../apache_1.3.20
    
  12. 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.