Installing PHP5

From DreamHost
Jump to: navigation, search
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes performed by DreamHost may break your modifications. You, as the user, are responsible for troubleshooting and resolving issues with your customizations.

Overview

PHP is installed by default on all DreamHost servers. Versions 5.3 and 5.4 are set to be removed from the DreamHost panel in early 2016. Versions 5.5 and 5.6 are recommended.

This article details how to install a custom version of PHP on a shared server. This allows you to install and build specific packages not available in the standard DreamHost shared installation of PHP.

Important icon.png Important: As mentioned above, DreamHost support is unable to assist in any way with this custom installation.


Download PHP

This article uses version 5.6.

  1. Visit the following link and download your desired version of PHP.
    You can also download it via SSH
    wget http://php.net/get/php-5.6.12.tar.bz2/from/this/mirror
    
    This saves to a new file named /mirror
  2. Make sure to check your downloaded file's checksum.
  3. Decompress the file:
    tar -vxjf mirror
    This creates a new directory named php-5.6.12

Installing PHP

  1. Create a /local directory.
    mkdir local
  2. Navigate to your PHP download directory:
    cd ~/php-5.6.12
  3. Run the following to install:
    ./configure --prefix=$HOME/local
    make
    make install
    
  4. Add your /local/bin/ directory to your user's PATH. Edit your .bash_profile and enter the following:
    export PATH=$HOME/local/bin:$PATH
    
  5. Add the following to your .bashrc file:
    source .bash_profile
  6. Run the following to update your .bash_profile in the current session:
    . ~/.bash_profile
  7. Check where your user is now locating the PHP installation.
    which php
    /home/example_username/local/bin//php
    
  8. Also check which version of PHP your shell is using:
    php -v
    PHP 5.6.12 (cli) (built: Aug 25 2015 15:36:15)
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    

See also