0

What is the proper way to install Drush 10 if I have a domain and several independently installed subdomains like described below? I want to avoid multiple drush installs.

On my shared hosting account, here is my directory structure for subdomains that are Drupal 8.7 and 9.0 sites. Originally, I was trying to install drush in the directory as shown below and set an alias in .bashrc alias drush='~/drush/vendor/bin/drush' so that I could run drush in any of the Drupal installs. Drush 10 isn't working that way. I haven't tried Drush 9 yet.

/home/account
   |
   |---drush
   |
   |----public_html <-- this is primary domain (currently just an index.html, but future Drupal)
          |
          |-------d87_site1 <---site1.domain.com
          |          |----vendor
          |          |----web
          |
          |-------d87_site2 <---site2.domain.com
          |          |----vendor
          |          |----web
          |
          |-------d9_site3 <---site3.domain.com
                     |----vendor
                     |----web

UPDATE: I seem to be successful incorporating your feedback, plus adding this added research to the solution:

  1. I installed drupal at the web root (hosted primary domain), but had to add this to my .htaccess file in the web root:
# https://www.inmotionhosting.com/support/domain-names/how-to-redirect-your-primary-domain-to-a-subdirectory/

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain_name.com$
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain_name.com$
RewriteRule ^(/)?$ subdir/index.html [L]

# end of how-to-redirect-your-primary-domain-to-a-subdirectory
  1. I was able to add alias drush='vendor/bin/drush' to .bashrc, so that I could run the each project-installed drush from each site root. I will try drush-launcher later.
  • 2
    It's now recommended to include drush in your project as a dependency via composer just like any other contrib modules, themes, libraries, etc. You should look at it the same way you look at any of those other dependencies. You wouldn't try to install one version of ctools, or paragraphs, or any other Drupal module in a directory outside your site like this, there's no reason to treat drush any differently. – sonfd Jun 20 at 17:52
  • 2
    You can globally install github.com/drush-ops/drush-launcher and it will always pick up each project's locally installed Drush automagically. – leymannx Jun 20 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.