… don’t know what drupal and drush are? Then this post is probably not for you…
Let’s face it – drush is a bitch to install. But we want it. So we have to. And install it we will!
Even though there appears to be extensive info on the topic on drush’s website, installing it may still be a daunting task.
Particularly – if you don’t run the latest version of php.
Why? Because the “extensive” installation instructions mostly deal with the default installation method which installs the latest version of drush.
…Which means – you’re using drupal 8 (but not all of us do!)…
…Which means – you have the latest php version installed (not all of us do!)
…Which means – you’re using the latest “composer” manager (again… you may not even have composer installed on your system).
SO… What are the ‘Les Miserables’ of us (who for one reason or another do not have the luxury of upgrading their setup to the latest and greatest drupal/php/composer!) to do?
Well… to install drush the standard way you need composer (https://getcomposer.org/doc/00-intro.md). And composer needs php version 5.3.2 or higher to run. So if your php is lower than that and you can not upgrade it then you’re even more screwed.
Your option (since you can not use composer to install drush) is to go to the drush git repository on github (https://github.com/drush-ops/drush) and find a version which is old enough to work with your php/environment.
Since drush versions (which are reflected in the git repo branch names) mimic drupal versions it should not be too hard to find a suitable drush version, knowing that drupal’s php dependencies are as follows:
- drupal 6 – PHP 5.2.5 or higher
- drupal 7 – PHP 5.2.5 or higher (>=5.4 recommended)
- drupal 8 – PHP 5.5.9 or higher
For the rest of us, whose setup is not THAT hopelessly outdated… 🙂 let’s continue with installing composer:
– – – Install composer – – –
1. Get the composer-setup.php script using the php command:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
If you feel security-freakish then go to the composer download page to verify the SHA code to make sure your downloaded file is correct.
The composer-setup.php file is what will actually install composer.
2. Choose a good location for composer (preferably within your PATH, for easy invocation).
In my case, since I have a ~/bin dir which is in my PATH, I installed composer there.
3. Install composer
From within your chosen directory run
Alternatively, to install a specific composer version you could run, e.g.
php composer-setup.php --version=1.0.1
The list of composer versions is available here: https://getcomposer.org/download and also there are direct download links for the specific composer versions (in case the composer-setup.php script above does not work).
4. You now should have a composer.phar file in your directory of choice. Use it to install drush. drush could be installed per-project (i.e. per drupal web-site) or globally for the user.
composer require drush/drush:7.x – get the latest 7.x version
composer require drush/drush:7.1.0 – to get version 7.1.0 (look up the drush versions in the drush git repo: https://github.com/drush-ops/drush[.git])
You should now have a vendor dir structure under your chosen directory and in it, in vendor/bin/drush will be your drush script.
Now, that’s great and all, but you’ll probably say “hey, but this way the drush command is not in your PATH!?”
You’re right! What I did to fix this, was to create a drush directory in my ~/bin dir and inside it add a drush7 dir where to install drush v7. I then symlinked the drush php file from the ~/bin dir (becasue it is in my PATH) and this way I have drush7 available on the command line 🙂
$ mkdir drush
$ mkdir drush/drush7
$ mv vendor drush/drush7
$ ln -s drush7 drush/drush7/vendor/bin/drush
Similarly you can install and create links for a drush6 and drush8 (if you need these versions) and thus have any version of drush available on the command line.
Now… the drush installer pages say that there is a way to install drush globally (using the ‘global’ command with the require drush command above… but I could not get that working for the life of me and I don’t recommend going that route. The above works and is relatively easy to understand and perform .. oh, and did I say it WORKS 🙂
- Android Development
- C programming
- Linux administration
- Linux device drivers
- Linux Gaming
- Linux kernel
- Linux Networking
- Linux on Windows
- Linux printing
- Linux sound and ALSA
- Package Managers
- Shell and environment
- Tips and tricks
- web development
- Wordpress Tips
- X Window System
- August 2020
- August 2019
- May 2019
- July 2017
- February 2017
- January 2017
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- April 2016
- March 2016
- December 2015
- November 2015
- September 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- October 2014
- February 2014
- January 2014
- November 2013
- October 2013
- June 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
Cloudaudio bash boot compile C programming cups drupal emacs etc Fedora git grep how to httpd init kernel libc linux linux partition localtime login make mount mp3 mysql networking oracle package managers password phpMyAdmin programming rpm shell sql vbox version control system virtual box vm web server wordpress www xargs xfce xwin yum