I have a site hosted on Hostmonster, and for a long time, I never really did much via the command line. However, I pretty much use drush for everything these days, and as I'm getting ready to upgrade to Drupal 8, I was going to need to update my version of Drush on the server (it was still 4.5... in 2016.) When I tried to update it via composer, I realized composer wasn't installed. When I tried to install composer via curl, I found out that it requires at least PHP 5.3, and I had 5.2.17. I updated PHP through cPanel, which updates what your website has, but doesn't update what you can use on the command line. I submitted a ticket, and after more than 3 days with no reply, I was about ready to cancel the account and move everything to A Small Orange (they have been nice to work with, even if the plans are more limited than Hostmonster.) Finally, I came across this article: https://laravel.io/forum/02-13-2014-how-to-install-laravel-on-a-hostgat…
In that article, he mentions how to update what version of PHP is available to you on the command line (there are multiple versions on the server, you just need to point to the version you want.) I followed the steps he listed about editing the .bashrc and .bash_profile files, ran source ~/.bashrc
, then php -v
and... "/opt/php55/bin/php: No such file or directory
" Crud... Turns out, since the time that article was written, the locations have changed. After some digging, I finally found that the correct, current location for the PHP libraries was under something like "/usr/php
" (for Hostmonster) or "/usr/local/php*
" (A Small Orange.) Additionally, as I found out the hard way, you need to use the CLI version of PHP. Once I got everything working, the content added to the TOP of .bashrc should be (updated for PHP 5.6 on Hostmonsters):
alias php='/usr/php/56/bin/php'
export PATH="/usr/php/56/bin:$PATH"
Note that the aliases for composer and drush are specifying the usage of the CLI version of PHP. Now, the content added to .bash_profile:
[[ -s ~/.bashrc ]] && source ~/.bashrc
Notice that this is using PHP 5.6. You should be able to use other versions if you need to. Now, when you run source ~/.bashrc
and php -v
, you will get:
PHP 5.6.30 (cli) (built: Feb 28 2017 11:51:09)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.1.2, Copyright (c) 2002-2016, by ionCube Ltd.
with SourceGuardian v11.0.6, Copyright (c) 2000-2016, by SourceGuardian Ltd.
with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies
You should now be able to install composer and update/install drush, as detailed in the Drush setup guide.