Setting up php-cli for drush on Hostgator

While using Drush on a client’s website I noticed that it was showing up headers when it shouldn’t be. It was showing ugly things like this:

Set-Cookie: SESSc21f969b5f03d33d43e04f8f136e7682=d4735ec22fbf70b7d55bc7bd80691ad4; expires=Sun, 02-Mar-2014 18:44:47 GMT; path=/
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Fri, 07 Feb 2014 15:11:27 GMT
Cache-Control: store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Content-Type: text/html; charset=utf-8

A little investigation showed that drush was running as with php CGI rather than CLI. It was a simple matter to find out the path to the PHP CLI and then to modify the alias to Drush and PHP in the .bashrc file (alternatively, you may have specified it in the .bash_profile or in .profile). So here’s what you SHOULD use:

export COLUMNS
alias drush='/usr/bin/php-cli ~/public_html/drush/drush.php'
alias php='/usr/bin/php-cli'

Leave a comment