[Drupal] Installing latest version of drush on Linux system and troubleshooting
https://www.zyxware.com/sites/default/files/styles/user_image/public/default_images/index.png?itok=2YmREnrP
BY abhai.sasidharan
4 years ago
Drupal
2
comments comment

The radical changes that Drupal 8 brought forward have been reflected in Drush 7 as well. Drush 7 now uses composer to download its dependencies. Before installing Drupal 8 you must make sure that Drush 7 has been installed. This is because Drupal 8 can be downloaded and installed using Drush like in the previous versions of Drush and also, Drupal 8 only supports Drush 7. Unlike earlier versions, Drush 7 cannot be installed using "sudo apt-get install drush" nor can it be updated by running "drush self-update" because that will result in updating to Drush 6 and no more. Hence the purpose of this article.

Drush is a powerful tool to manage routine tasks in a Drupal site. Downloading, installing or enabling modules, running cron and much more can be accomplished using Drush. This is why its important to have Drush 7 before a Drupal 8 installation. Drupal 8 requires minimum version of PHP 5.4. Apache requirements haven't been mentioned, but I recommend apache2.4. After this we can begin installing Drush 7.

Installing Composer

As I have mentioned earlier, Drush uses composer to install its dependencies, so first we have to install composer. Install composer globally on your system or server because with Drupal 8 composer will be required quite often.

  • To download composer, you will have to run the command "curl -sS https://getcomposer.org/installer | php". Make sure you have permissions. Run this command from the home folder. If curl is not installed in your system, run "sudo apt-get install curl". curl is a tool to transfer data from or to a server, using one of the supported protocols. Run "man curl" for more details.
  • After it has been downloaded, run "sudo mv composer.phar /usr/local/bin/composer". Now you can run "composer --version" to see if its working.

Installing Drush

  • Remove any earlier versions of Drush if installed, otherwise it will cause conflicts.
  • Run "composer global require drush/drush:dev-master" from the home folder. Make sure you have permissions or run with sudo. This will give you the latest version of Drush.
  • If all goes well you will see an output like this :
      
        Changed current directory to /home/user/.composer
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing pear/console_table (1.1.5)
        Downloading: 100%
     
      - Installing symfony/yaml (v2.2.1)
        Downloading: 100%
     
      - Installing d11wtq/boris (v1.0.8)
        Downloading: 100%
     
      - Installing drush/drush (dev-master 6ce7202)
        Cloning 6ce72029d154abe9cf8d0a7c8d7ebf44d511294a
     
    pear/console_table suggests installing pear/Console_Color (>=0.0.4)
    drush/drush suggests installing youngj/httpserver (dev-master#41dd2b7 as 1.0.1) 
       
    
  • This will install in the directory: ~/.composer/vendor/drush/drush, so we will have to set path.
    • ln -s /home/<linux user name>/.composer/vendor/drush/drush /usr/bin/drush
    • export PATH="$PATH:/home/<linux user name>/.composer/vendor/drush/drush:/usr/local/bin"
  • Run "drush status" to see if drush has been installed.
  • We have to edit the .bashrc file and include the export statement in it, otherwise the PATH variable set will not be reflected in every bash terminal instance.
    • Run "gedit .bashrc" on terminal at the home folder. If .bashrc does not already exist, you can create one now.
    • At the beginning of the document, include the line " export PATH="$PATH:/home/<linux user name>/.composer/vendor/drush/drush:/usr/local/bin" ", save the file and exit.
  • The .bashrc file will be executed every time the terminal or any bash console is run. This will set the PATH variable every time bash runs.
  • Open a new terminal and run "drush status" to see whether this has worked.

Troubleshooting

If running "drush status" gives an error "drush is not installed. Run sudo apt-get install drush", then either Drush installation did not go as planned or the PATH variable was not set properly.

  • Run "echo $PATH" and check whether Drush path is there in your PATH variable.
  • This is how a normal PATH variable looks in an ubuntu system :

    /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/user/.composer/vendor/drush/drush:/usr/local/bin

  • Make sure you did not change anything else in the .bashrc file and that you have write permissions.
  • Go to the Drush installation folder: .composer/vendor/drush/drush and check whether Drush has been downloaded there. This can happen if, either you did not have the required permissions or if there was a problem with connection on either end and the request timed out.
  • In that case run "composer global require drush/drush:dev-master" again or navigate to .composer/ folder from terminal and run "composer update drush"
  • To update composer, navigate to .composer/ and run "composer update". This will also update drush/drush:dev-master.

Drush is important and essential to work alongside with Drupal.With composer, a powerful dependency manager, it is easier to download and install Drush. Once set up, Drush 7 and Drupal 8 is something that gets any web developer excited!

References:


RELATED ARTICLE

close

on 01st January 2008 / by webmaster
We have added a few new modules to our site recently. Two of these are the StumbleThis module and the DiggThis module. Drupal already had a DiggThis module available for download but there was no StumbleThis module. StumbleUpon has been a popular source of traffic for zyxware.com and we wanted users to have an option to add any of our pages to their StumbleUpon favorites. So we created our own StumbleUpon module. Normally people use stumbleupon toolbar to stumble websites. However when the toolbar is not enabled this provides an easy way to add the URL to the stumbleupon favorites. The StumbleThis button will be shown on the left of the content inline. Positioning of the StumbleThis button can be controlled by the weight option in the admin menu. By setting a negative value you can have the button displayed on top of the post while a positive value will take it to the bottom of the post.Click here to download the StumbleThis module for Drupal. The module has been tested with Drupal 5.1. Please use the comments form below if you have any questions or suggestions. Open Source Web Development Drupal Blogging Free Software Drupalgive Leave a reply Your email address will not be published. Required fields are marker * Sean (not verified) access_time 24 May 2019 - 15:56 Hi there, I uploaded the files, enabled the modules to use SU, and now I see the link, but there is no icon... How can I fix this? Thanks, Sean webmaster access_time 24 May 2019 - 15:56 In reply to Icon doesn&#039;t show by Sean (not verified) What do you see when you view the source? Search for stumblethis_button and you should be able to see the code for the image and the URL. Then you should be able to troubleshoot from there. Juicy Couture Addict (not verified) access_time 24 May 2019 - 15:56 thanks for the post. would love to hear more of you. by the way, drupal's really popular nowadays as it has easy and fast features. you agree with me? thanks. Add new comment
more_horiz
close

on 16th January 2008 / by webmaster
Most webmasters do not realize this, but a lot of the content on lot of websites can be accessed from multiple URLs. A simple example would be where www.example.com and example.com leads to the same page. This is a fatal mistake in Search Engine Optimization and search engines penalize you for duplicate content. The correct configuration would be where the above two urls will lead you to the same page but example.com will redirect you to www.example.com with a 301 (Moved permanently) status which will not result in search engines penalizing the page. It is very easy to configure 301 redirects using Apache .htaccess file and the process is the same for a Drupal installation also. The article is relevant only to those webservers running Apache. There are two ways in which you can issue a 301 redirect using .htaccess on an Apache Webserver. One is using a mod_alias Redirect statement and the other is using the mod_rewrite Rewrite statements. Redirect statements take paths and assign corresponding paths to be redirected to while rewrite statements take regular expression patterns and associate paths where matched urls have to be redirected to. When you install Drupal, it will automatically insert statements in the .htaccess file that will allow you to redirect www.example.com to example.com or vice versa. The only thing you have to do normally would be to uncomment the statements corresponding to your preference of accessing your domain ie with or without the www part. # If you want the site to be accessed WITH the www. only, adapt and # uncomment the following: # RewriteCond %{HTTP_HOST} ^example\.com$ [NC] # RewriteRule .* http://www.example.com/ [L,R=301] # # If you want the site to be accessed only WITHOUT the www. prefix, adapt # and uncomment the following: # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] # RewriteRule .* http://example.com/ [L,R=301] There is however a problem with the above redirections in that they lose the rest of the URL. Say for example if you try to access example.com/somepath and your configuration is to use the www prefix the user will be redirected to www.example.com but the somepath part will be lost. This can easily be rectified by the following small change in the Rewrite Rule # For the first option you can use the following rewrite rule # RewriteRule (.+) http://www.example.com/$1 [L,R=301] # # whereas for the second you can use the following rewrite rule # RewriteRule (.+) http://example.com/$1 [L,R=301] These modifications will ensure that the user will be redirected to the correct page with or without the www prefix and without losing on your page ranks. So make the necessary modifications and make sure that you can access the pages to your site using only one version of the URL. The above configuration of .htaccess should be used not just for Drupal websites but for all websites. If however your problem is the reverse, ie you don't have pages corresponding to the URLs that the user typed, ie if you are getting lot of 404 errors (page not found errors) and users are thrown to the default Page not found page, you can try installing the Drupal Search404 Module to search for the keywords in the URL and show relevant results to the user. You can read more about apache mod_alias and apache mod_rewrite at the apache official documentation Apache mod_rewrite and Apache mod_alias Web Development Drupal SEO Drupal Planet Leave a reply Your email address will not be published. Required fields are marker * Anonymous (not verified) access_time 24 May 2019 - 15:56 Hello. I'm trying to make example.com show as www.example.com, and I'm running into difficulties. I'm on Apache 2.0 and using the following lines in my httpd.conf file: RewriteEngine on RewriteCond %{HTTP_HOST} ^xxxxxxxxxx\.com$ [NC] RewriteRule ^(.*)$ http://www.xxxxxxxxxx.com/$1 [L,R=301] When I go to http://xxxxxxxxxx.com, I get http://www.xxxxxxxxxx.com (as expected). However, when I go to http://xxxxxxxxxx.com/node/1 (it's a Drupal site), I get a 404 thrown and the URL changes to xxxxxxxxxx.com/var/www/drupal/node/1. Same thing with www.xxxxxxxxxx.com/node/1. Any suggestions? I want to run without Drupal's .htaccess file (instead incorporating these calls into my httpd.conf file). webmaster access_time 24 May 2019 - 15:56 In reply to Rewrite including filesystem path by Anonymous (not verified) I think the problem is with the base path which results in the redirection to /var/www/ part. The best approach I would think is to start with drupal htaccess and then strip out parts and move to httpd SNVC (not verified) access_time 24 May 2019 - 15:56 This is definitely a good guide. Thanks for this. wellyson access_time 24 May 2019 - 15:56 This is really nice and helpful. Add new comment
close

on 07th January 2008 / by webmaster
We have volunteered to take up the maintenance of a very useful Drupal module - Search404. As of today we are the official maintainers of this very useful Drupal module. We know that this is going to be a challenge for us, being a young company and with a young team. But we do feel that it is our responsibility to give back to the Drupal community at least some part of what it has given us. About Search404 Module Normally when a user types in an incorrect URL in a site the web server will issue a 404 error (page not found error) and correspondingly redirect you to a 404 error page. If there is no custom 404 page on the server the browser will show the 404 page not found error to the user. This could happen when either the user types in the URL himself or he clicks on a URL incorrectly typed in another page. Another case when such errors happen is when content is deleted or moved in a site and the search engine indices have not been updated to reflect the removal or change. The web crawlers of search engines on getting a 404 error will take out the URL from their indices. The normal web user will however be totally lost when he sees the 404 error page. This is especially true if the user came from a search result page and has no idea about the navigational structure of the site or the content organization of the site. Drupal however shows its own 404 error page and avoids showing the grotesque, default 404 page that would otherwise be shown by the browser to the end user. Even this 404 error page is only a bare page with just the information that the page cannot be found. The Search404 module intelligently does a search for the terms in the URL while still issuing a 404 error. This will ensure that the URL gets taken out from the search engine index at the same time making sure that the user is given some options in terms of navigating in the site. You can check out how this works by clicking on the following non-existant URL Drupal Modules from Zyxware. Even though the page does not exist you get what you wanted to get to. If you have any questions, issues or suggestions regarding this module you can either post them as comments to this page or post your issues at the Search404 Module at Drupal.org. Open Source Web Development Drupal Leave a reply Your email address will not be published. Required fields are marker * ian douglas (not verified) access_time 24 May 2019 - 15:56 I notice your updates on the Drupal modules page has some patch files, but they are patches for an older version of the 5.x branch of search404. Do you have any expectation on when a version for Drupal 6 will be ready? webmaster access_time 24 May 2019 - 15:56 In reply to when will search404 for drupal 6 be ready? by ian douglas (not verified) Hi Ian, We are currently working on moving Search404 to Drupal 6. The port has already been done and we should have a release up on drupal.org by tomorrow or worst case by monday. Cheers Anoop John Team Zyxware Dejan (not verified) access_time 24 May 2019 - 15:56 In reply to when will search404 for drupal 6 be ready? by ian douglas (not verified) I think that's been up for a while... did you check the download page? Add new comment
Leave a reply
Your email address will not be published. Required fields are marker *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

author-image
Anonymous (not verified)
access_time 24 May 2019 - 16:36

hey !
many thanks for this page.
I would like to add my story :
- I'm using ubuntu via ssh
- after having set the $PATH into .bashrc and starting a new ssh session, nothing happened. still the message : "drush is not installed. Run sudo apt-get install drush"
- I had to put the PATH config into ~/.bash_profile to make it work.

just my two cents ;)


author-image
kjohnah (not verified)
access_time 24 May 2019 - 16:36

very helpful guide but the path where composer downloads drush is different on ubuntu 16. So one needs: sudo ln -s ~/.config/composer/vendor/drush/drush /usr/bin/drush
and then:
export PATH="$PATH:~/.config/composer/vendor/drush/drush:/usr/bin"
Also the editing the bashrc file might be unnecessary as it does not affect the output of drush status afterwards