How to install Drush on cPanel Shared Hosting

How to install Drush on cPanel Shared Hosting

The Drush command-line utility is only available on platforms that have php-cli. This means that this will only work in cPanel shared hosting. Drush is not able to be installed in any 4GH Linux shared hosting account. This article is meant to assist advanced users who are already familiar with using SSH.

Drush is a command-line utility for the Drupal web application. It provides advanced functionality for powerusers who wish to manage their Drupal site via SSH. These advanced functions include rapidly clearing the Drupal cache, installing and managing additional extensions such as security modules, and being able to quickly backup, restore, and deploy Drupal sites in one location or over a network. More information on the different options available for Drush can be obtained at Drush's support site. An excellent resource for learning and using the commands included in Drush is drushcommands.org. This guide will outline how to properly install Drush to a cPanel shared hosting account, and these external resources can better assist you in using the Drush Utility

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
TIME REQUIRED 15-30+ min
RELATED PRODUCTS Shared cPanel

Obtaining the Drush files

Log in to your cPanel hosting account via SSH. Make sure SSH is enabled for your IP before connecting.

Once logged in, make sure you are in the home directory of your hosting account. You can ensure this by using the command pwd to print the working directory. It should show you as being in /home/username, where username is your primary username for cPanel.

From your home directory, use the wget command to get the newest version of Drush. We suggest getting this directly from Drush's master GitHub, to ensure that it is always the most up-to-date version of Drush.

wget https://github.com/drush-ops/drush/archive/master.zip

You now have a .zip of the most up-to-date version of Drush, in your home directory.

Installing Drush files

Unzip the drush file archive by using the following command

unzip -q master.zip

This will unzip the files to the ~/drush-master directory. For the ease of use, lets rename this directory to simply be 'drush', by using the following command:

mv ./drush-master ./drush

You should now have a directory in your home directory named 'drush”.

Now we need to update our .bashrc file so that bash executable knows to recognize the alias 'drush.' You may do so by adding the following line to the .bashrc file in your home directory.

alias drush='~/drush/drush'

This can be done by using your favorite text editor, such as Notepad++ or directly in SSH by using vim. If you have never edited your .bashrc file for any other reason, then you can simply add this line to the file by running the following command:

echo "alias drush='~/drush/drush'" >> .bashrc

Installing Composer

PHP composer is a PHP dependency management suite that allows PHP to do the heavy lifting for you, ensuring that PHP knows which libraries to use when executing drush commands. This section will show how to get Composer, then properly use composer to complete the install of drush.

Navigate to the drush directory by using the cd command.

cd drush

Use the curl command to grab the composer files, then pipe them to PHP to be executed. This is done by using the following command.

curl -sS https://getcomposer.org/installer | php

You should see an output regarding the settings of composer.

Run the command that composer provides to you to properly install Drush.

php composer.phar install

You will see an output of different dependencies that are installed for Drush. Composer should now complete the dependency installs for Drush

Cleanup

So all the important stuff is done now, we just need to do a couple last things, and confirm that Drush is now running.

Navigate back to your home directory. This is easily done with the command:

cd ~

Now that you are back in your home directory, you need to reset your bash settings for your user so that it takes the new alias that you previously added to your .bashrc file. This is easily done by running the following command:

source .bashrc

Now, lastly to confirm that drush is running, type the command:

drush help

This should list the commands available to you via Drush.

There you are! Drush is now installed on your shared hosting account. Use the cd command to Change Directory to the document root for your Drupal site, and you can now start easily managing the site via command line.


Рекомендовать в Социальных сетях:
 

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *