How to install Drush globally?

Member

by avis , in category: PHP , a year ago

How to install Drush globally?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by silas_gulgowski , a year ago

@avis 

To install Drush globally, you can follow these steps:

  1. Install Composer: Drush requires Composer to manage its dependencies. If you haven't installed Composer yet, you can download and install it from https://getcomposer.org/download/.
  2. Install Drush: Once Composer is installed, open a command prompt or terminal and run the following command to install Drush globally:
1
composer global require drush/drush


  1. Add Drush to your PATH: Once Drush is installed, you need to add its executable file to your system's PATH environment variable so that you can run it from anywhere. To do this, open your terminal or command prompt and run the following command:
1
export PATH="$HOME/.composer/vendor/bin:$PATH"


Note: This command is for Mac and Linux users. If you're using Windows, you'll need to add the path manually.

  1. Verify installation: To verify that Drush is installed correctly, run the following command:
1
drush --version


This should output the version of Drush you just installed.


That's it! You've now installed Drush globally and can use it to manage your Drupal sites from anywhere in your system.

by jerald.kuvalis , 3 months ago

@avis 

Note: If you encounter any permission errors during the installation process, you may need to run the commands as an administrator or use the "sudo" prefix.


Additionally, if you already have an older version of Drush installed on your system, it is recommended to uninstall it before installing the new version. You can run the following command to uninstall Drush:

  1. composer global remove drush/drush


Then proceed with the installation steps mentioned above.


If you're using WAMP or XAMPP on Windows, you might need to update your environment variables manually. Here's how:

  1. Open the System Properties window by right-clicking on Computer or My Computer and selecting "Properties".
  2. Click on the "Advanced system settings" link.
  3. In the System Properties window, click on the "Environment Variables" button.
  4. In the "User variables" section, select the "Path" variable and click on the "Edit" button.
  5. Add the path to the Drush executable (usually located at C:Users[YourUsername]AppDataRoamingComposer endorin) at the end of the "Variable value" field. Make sure to separate it from the existing values with a semicolon (;).
  6. Click "OK" to save the changes.
  7. Close and reopen the command prompt or terminal for the changes to take effect.


Now you should be able to run the drush command from anywhere in your system.