Drush - Installing on Hostmonster - shared server

cd ~
wget https://github.com/drush-ops/drush/archive/refs/tags/8.4.8.tar.gz -O drush.tar.gz
tar -xzf drush.tar.gz
mv drush-8.4.8 drush
rm drush.tar.gz
 
nano ~/.bash_profile
# If you need to specify a particular version of PHP for Drush
# to use, add the following line to .bash_profile (example uses PHP 7.3):
export DRUSH_PHP=/opt/cpanel/ea-php73/root/usr/bin/php
 
# Create the ~/bin folder if it doesn't already exist
cd ~
mkdir bin
 
# Add the following line to .bash_profile
export PATH=$PATH:$HOME/bin
 
# Then create a symbolic link to drush in ~/bin by issuing the following command:
ln -s ~/drush/drush ~/bin/drush
 
# Either login and logout or reload .bash_profile:
source ~/.bash_profile
 
# Install composer in drush folder
cd ~/drush
curl -sS https://getcomposer.org/installer | /opt/cpanel/ea-php73/root/usr/bin/php
 
# Create an alias to composer
nano ~/.bash_profile
# Add the following line to .bash_profile
alias composer="/usr/local/bin/php ~/drush/composer.phar"
 
# Either login and logout or reload .bash_profile:
source ~/.bash_profile
 
# In the drush root, run Composer to fetch dependencies
composer install
 
# Check that drush is working:
drush --version

To access the server remotely, create an alias file. For example ~/.drush/example.aliases.drushrc.php that looks like this:

<?php
$aliases['prod'] = array(
  'remote-host' => 'example.com',
  'remote-user' => 'exampleuser',
  'root' => '~/public_html/example/docroot',
  'uri' => 'example.com',
  'path-aliases' => array(
    '%drush-script' => '/drush/drush.php',
  ),
  'php' => '/opt/cpanel/ea-php73/root/usr/bin/php',
);

Internal References

Article Type

General