Running PHP5 in the Dreamhost CLI

Some times a PHP framework might include a command line interface, Cake PHP or Symfony for example have a tool that will generate some code based on your database.

Symfony unlike Cake PHP will only work with PHP 5, When I tested the version of php on the front end I got 5.2.4 and figured I’m good to go.

While after running the Symfony command line tool to build my project I got a php error.

This is due to the setup of most shared web hosting environments PHP is run as CGI, or FastCGI rather than mod_php.

My knowledge of the command line is just enough to make trouble for myself and the support team.

As the Symfony documentation stated I checked the CLI php version and found it to be 4.4.9 using php -v and that the configuration would not work with Symfony.

I had a look in the DreamHost Wiki and found this could be fixed by adding an alias to your path.

DreamHost by default has PHP installed with the option to run php 5.

  • PHP 4 – /usr/local/bin/php
  • PHP 5 – /usr/local/php5/bin/php
  • PHP 5.3 – /usr/local/php53/bin/php

Open your .alias file using FTP or command line.

Add the following alias to the bottom of the file.

alias 'php=/usr/local/php5/bin/php'

This should work for any web-server but the path will be different.

Signup for my mailing list

Receive other rambings like this on design, code, and some times food.