How to install a custom version of PHP

PHP versions 5.6 and above are installed by default on all DreamHost servers, but you can still install your own custom version if you wish.

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.

DreamHost support is unable to assist in any way with this custom installation.

Download PHP

This article uses version 5.6.

  1. Log into your server via SSH.
  2. Make sure you're in your user's home directory by running the following command:
    [server]$ cd ~
  3. In a browser, visit the following link to choose your desired version of PHP.
  4. Click the .tar.bz2 link. This takes you to a page where you can select a mirror site. In this example, scroll down to the 'United States' and right click the link for From the popout menu, choose 'Copy link address'.
  5. Back in your SSH terminal, download the file using wget. Type in 'wget' and paste the link you just copied.
    [server]$ wget
    This saves to a new file named /mirror
  6. Make sure to check your downloaded file's checksum. Compare it to the version on the downloads page above.
    [server]$ md5sum mirror
  7. Decompress the file:
    [server]$ tar -vxjf mirror
    This creates a new directory named php-5.6.12

Installing PHP

  1. Make sure you're in your user's home directory by running the following command:
    [server]$ cd ~
  2. Create a /local directory in your user's directory.
    [server]$ mkdir local
  3. Navigate to your PHP download directory:
    [server]$ cd ~/php-5.6.12
  4. Run the following to install:
    [server]$ ./configure --prefix=$HOME/local
    [server]$ make
    [server]$ make install
  5. View the creating and editing a file via SSH article for instructions on how to edit your existing .bash_profile. Then enter enter the following line. This adds your /local/bin/ directory to your user's PATH.
    export PATH=$HOME/local/bin:$PATH
  6. Save and close the file and return to your shell.
  7. Run the following to update your .bash_profile in the current session:
    [server]$ . ~/.bash_profile
  8. Check where your user is now locating the PHP installation.
    [server]$ which php
  9. Also check which version of PHP your shell is using:
    [server]$ 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

Internal links

External links

Did this article answer your questions?

Article last updated .