Question

How to install Drush without root access on a shared cPanel server?

Hi,

I have a shared cPanel Linux server and I don’t have root access to install drush. Can you please provide me with a step by step instructions guide on how to do that?

Thanks!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 29, 2019
Accepted Answer

Hello,

In order to do that you would need SSH access. Then SSH to your server:

ssh your_user@yourserver.com

Then check if you have composer installed:

which composer

If you don’t get any output install composer:

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

Then move the composer.phar file to your local bin folder:

mv composer.phar ~/bin/composer.phar

Find the the path to your PHP binary:

which php

You should get something like this:

/opt/cpanel/ea-php72/root/usr/bin/php

In your .bashrc file add the following:

alias composer="/opt/cpanel/ea-php72/root/usr/bin/php ~/bin/composer.phar"

Then run:

source ~/.barhrc

That way you would be able to use the composer command without havint to specify the full path each time.

After that, you can install Drush with:

composer global require drush/drush:dev-master

Then again to save some time you could add the following alias in your .bashrc:

alias drush="~/.config/composer/vendor/bin/drush"

Run source again:

source ~/.barhrc

And finally drush should be available, try it by runing just:

drush

Hope that this helps! Regards, Bobby

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.