欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Installing Drush on Windows

shiping1 的头像
With Drush you can greatly reduce the amount of time needed to setup and upgrade your Drupal installations - even if you're not a command line expert. If you haven't used Drush yet, you've probably at least heard of it.

This walkthrough will list the steps to get Drush setup on Windows. I'm using WAMP for my localhost. If you're using something else some of your paths might be different, but the setup process is the same.

Drush is a command line shell and Unix scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

To learn more about getting started with Drush, watch the screencast Drupal School: Jumpstart with Drush and Command Line.

Get Drush

Download the Drush project from drupal.org.

Where to Install Drush?

Drush is not a module, not specific to a Drupal site or Drupal version (5.x, 6.x...). While you can place it in sites/all/modules, it makes more sense to install it outside of your Drupal directory for example in C:/ or C:/wamp/www.

Installation on Windows

  1. Install additional applications:
  2. Use bsdtar for tar, it's more reliable. Copy the file C:\Program Files\GnuWin32\bin\bsdtar.exe toC:\Program Files\GnuWin32\bin\tar.exe

    http://drupal.org/node/594744

  3. Setup PATH environment variables for Drush, PHP, and tar/get/wget binaries installed above:

    Control Panel > System > Advanced System Settings > Environment Variables

    Select Path and click Edit.

    Append your paths (separated by semicolons) to php.exe, drush.bat and tar/get/wget binaries to the Path Variable value. This field is not so usable as a textfield. You'll probably want to copy the existing value to a text editor, append your new entries and paste everything back into the field.

    You're paths should look something like this, but they may be different depending on your setup.

    ;C:\wamp\bin\php\php5.3.0;C:\drush;C:\Program Files\GnuWin32\bin

    MySQL Path

    Check to make sure your Path variable includes the path to the folder containing mysql.exe. While this isn't necessary to use Drush, being able to use MySQL via the command line comes in handy.

    ;C:\wamp\bin\mysql\mysql5.1.36\bin

    Environment VariablesSystem Properties

    Edit Path System Variable

    If you have an open command window, you will need to reopen it to refresh your path variables.

  4. Edit drush.bat located in the root of your Drush folder to include the full path to your PHP installation.

    @C:\wamp\bin\php\php5.3.0\php.exe "%~dp0drush.php" %*

Testing your Drush Setup

Open the Command Line, type drush or drush --help and hit enter. If installed correctly you should see a help listing of Drush commands.

Drush Command Line

Comments

 

Well I don't know what's wrong with my installation. I get everything right from the post. The version is showing, the help is showing, the commands are showing.
BUT whenever I try and use them it says:
"wget nor curl executables found"

Maybe I got this step wrong:
"Use bsdtar for tar, it's more reliable. Copy the file C:\Program Files\GnuWin32\bin\bsdtar.exe to C:\Program Files\GnuWin32\bin\tar.exe

http://drupal.org/node/594744"

Can anyone help please?

 

Nice guide.
Installation success.

Thx so much for ur guide :D

 

C:\Users\Fito>drush
Unable to load autoload.php. Drush now requires Composer in order to install its
dependencies and autoload classes. Please see README.md

 

Definitely consider that that you stated. Your favourite reason seemed to be at the net the easiest factor to take into accout of.
I say to you, I definitely get irked whilst other people consider concerns that they just don't understand about.
You controlled to hit the nail upon the top and also outlined out
the whole thing without having side effect , other people can take a signal.
Will probably be again to get more. Thank you

 

comment_body[und][0][value]

 

Very Nice tutorial...

Thanks a lot!

 

Anybody know what i'm doing wrong based of this error i'm recieving after i type drush:

Uncompressing C:\drush/lib/drush-library-2046223423.tar.gz using the [error]

gzip command failed.

 

I could not get the 2nd point "Use bsdtar for tar, it's more reliable. Copy the file C:\Program Files\GnuWin32\bin\bsdtar.exe to C:\Program Files\GnuWin32\bin\tar.exe"
both are in the same directory

 

I followed the instructions, But no success http://drupal.org/node/1357718, I am getting "install profile-error unknown options:--prepare-install,--working-directory "
Can you please help me ?

 

"Command Prompt shell optimized for Drush" is all that appears when I go to the Windows 7 Pro command prompt. If I start a Drush prompt. When I execute a command like "drush dl drush_make-6.x-2.3", I get "Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes) in D:\ProgramData\Propeople\Drush\includes\bootstrap.inc on line 913"

Any ideas what may be wrong?

Thanks.

 

This is an awesome post but I struggled with drush make (drupal.org/projects/drush_make) configuration.
Finally got it working following instructions from http://drupal.org/node/1260084
especially part where the drush_make is downloaded:
(type in command prompt): drush dl drush_make-6.x-2.3 (project drush_make contains 0 modules - OK) - will download drush_make in C:\users\user_name\.drush

That was the crucial piece I was missing, the drush_make should be in the users\my_windows_user directory, under .drush (notice the dot in front of .drush folder name)

 

oooook... what if you drupal installation isn't local and you are starting out with drush... how do I connect drush to the online installation

 

Great resource. God bless you for such a wonderful step-by-step tutorial.

 

Was dying to install Drush for very long time. Didnt know its this easy.. May be the blog made it very easy :) Thanks Jocelyn

 

You Beauty!
The only slight difference I had was in point 4 I didn't need to change anything as it was already pointing to php installed with drush.

 

The best around!

 

nice tutorial works like a charm

 

So, I think I did everything correctly... but I'm getting this message on the command line:

drush
'C:\wamp\bin\php\php5.3.4php.exe' is not recognized as an internal or external c
ommand,

I apologize for my "newbiness" if this is an obvious mistake... but does anyone know what the problem is?

 

Nevermind! I found it, it was just a missing '\' in the path in the drush.bat file. Sorry... now I feel like an idiot =/ Anyway, thank you so much, this was a great tutorial!

 

For anyone getting a php5ts.dll missing error and using acquia stack:
http://drupal.org/node/506448#comment-4585172

 

Thank you for posting this! :D It's just what the doctor ordered.

 

Drush_make on Windows...
Put drush_make in the following location:
drush/commands/drush_make

 

For those unfortunate Windows user (myself include at the moment). Put drush_make in the following location: drush/commands/drush_make

 

Very nice, ages waiting to get this to work!!!!

 

Thank you SO MUCH for this ! I've been looking for a simple way to get Drush to work using the Windows command line (Powershell), and you wrote the first one that ACTUALLY WORKED !

 

I get the help screen fine but ...
Unable to download drupal-6.19.tar.gz to C:/wamp/www/ from

http://ftp.drupal.org/files/projects/drupal-6.19.tar.gz
An error occurred at function : drush_pm_download

when i use the drush dl command - any suggestions?

 

Any tips on how to install drush make

 

That's awesome, thanks for the guide and to Seb for the 'Console_Table' not found error fix.

Had to set this up on a windows box after having to move from a mac setup.

 

Great instructions. Worked first time for xampp just changing paths where necessary. Thanks!

 

Great, you helped me lots.

 

Great, just what I needed.

Thanks!

 

for those who get the error message ""Class 'Console_Table' not found"

go to comment #3 on http://drupal.org/node/563170. Works like a charm!

Thanks for this post Jocelyn!

 

nice installation guide...
thanks!

 

MMmmmuah! muchas gracias :)


 

来自 http://ninjagirl.com/posts/2010/06/installing-drush-windows

Last updated August 21, 2015. Created on October 3, 2009.

Edited by Manjit.SinghSebCorbinpkiffhansfn. You can edit this page, too.

Install Drush on Windows - The easy way.

Follow the Windows-specific instructions provided on Github: 
http://docs.drush.org/en/master/install/#windows-zip-package

You should find a link to a Windows installer there. Here is the current link (as of 28 January 2015):
https://github.com/drush-ops/drush/releases/download/6.0.0/Drush-6.0-201...

The Windows installer is compiled and managed separately from the rest of the Drush github repository, and so you should not be surprised if the MSI installer version offered does not quite match the latest version of Drush.

As of September, 2014, the Drush 6 Windows installers works well on Windows XP, Vista, 7, and 8. This is the recommended method for installing Drush on Windows. It is is much simpler than the manual processes described below.


You may want to read the either of the following articles if you want to install Drush 6 or 7 on a Windows machine.


How to manually upgrade to Drush 5.x and 6.x on Windows XP and 7

Drush 5.7 Makes does not work in Windows 7 - but drush 6 does!

The Drush Make command does not work in Windows 7 / Vista, when using Drush release 5.5, 5.6, or 5.7. However, the current development version of Drush fixes this issue!

So, if you still cannot find an suitable Drush installer for your Windows version, take a look at this article, How to manually upgrade to Drush 5.x and 6.x on Windows XP and 7, which provides detailed instructions for manually installing the latest development version of Drush in Windows.


Install Drush on Windows - The hard way.

The most recent official Drush readme.txt file contains the basics of installing drush. Some special considerations need to be made when installing on windows. The following Tutorial is for Drush 5 and based on the process outlined at: http://drupal.org/node/330023 

Some people recommend viewing Installing WAMP, Drush & Drupal on Windows 7 which follows the instructions below.

Follow the instructions below to install Drush on Windows the hard way (possibly useful if you had trouble with the installer above).

Step by Step

  1. Open http://drupal.org/project/drush and download and extract "All-versions-5.x-dev" to C:\ so drush.bat can be found at C:\drush\drush.bat.
  2. Install the following external applications.
  3. Use bsdtar for tar. Its more reliable. Copy the file C:\Program Files\GnuWin32\bin\bsdtar.exe to C:\Program Files\GnuWin32\bin\tar.exe
  4. Set PATH environment variable to include drush, php, and binaries installed above.
    add something like this line to the end of the current value
    ;C:\php;C:\drush;C:\Program Files\GnuWin32\bin

    Note : If you have different path of php then change it.
    In my case i have following path
    ;C:\xampp\php;C:\drush;C:\Program Files(x86)\GnuWin32\bin

    The semicolon separates the paths. Paths are those to: php.exe, drush.bat location,and tar/gzip/wget binaries. You will need to reopen your shell/command prompt window to have the path variables refreshed.
    or enter on the command line: setx PATH "%PATH%;C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\GnuWin32\bin;C:\Program Files (x86)\Drush\Php;C:\Program Files (x86)\Drush\cwRsync\bin;"
  5. Open the Command Prompt, type "drush status" and hit enter. You should see the following output:
      PHP configuration      :  C:\php\php.ini
      Drush version             :  5.0-dev
      Drush configuration   :
      Drush alias files         :

    If you did, installation is complete. If not, keep on reading.

  6. This step may no longer be needed. See comments.
    Now you need to locate your drush.bat file which is located in the root directory of your drush module
    "C:\path-to-drush\drush.bat".
    Open this file and append the full path to the drush.php file:
    c:\php\php.exe C:\drush\drush.php %1 %2 %3 %4 %5 %6 %7 %8 %9
    For drush-2.1/3.1:
    You just need to put the full path to php, no need to put the full path to drush:
    c:\php\php.exe "%~dp0drush.php" %1 %2 %3 %4 %5 %6 %7 %8 %9

Check how to upgrade drush in windows to work with drupal 8
here.


Other How Tos for Installing Drush on Windows

Gotchas for Windows

Configuration files (i.e. site alias files) locations

If you are using the drush.ws Windows installer and have not modified the installation paths, etc., finding where to set up your Drush alias files is challenging. The information is there, but not readily accessible. Drush will look through a sequence of directories, each less specific to a site than the other as defined in the C:\ProgramData\examples\example.drushrc.php file. In those comment, the references are for Linux based operating system. On Windows the following locations should help:

  • #4, the User's .drush folder, is usually located at C:\Users\user_name\.drush. But that location is determined by the environment variables HOME or HOMEDRIVE/HOMEPATH. Double check by a SET command at the command line.
  • #6, the Drush installation folder, is usually located at C:\ProgramData\Drush. In this case do not use a .drush subdirectory, put the files into the installation folder.

Install Script

Notes below Will be converted into batch install script

# install gzip, tar, wget command line binaries
# download drush.  Using c:\drush as location in this example
# set PATH environment variables
# edit drush.bat

Above Directions Work on...

  • Windows server 2008. R2 Tested by: johnbarclay (11/14/2010)
  • Windows server 2008. Tested by: johnbarclay (10/2/2009)
  • Windows Vista 64-bit Business. Tested by: Gman (10/20/2009)
  • Windows Vista 32-bit Business. Tested by: buckley (2010-01-10)
  • Windows Vista 32-bit Home Premium. Tested by: decibel.places (2010-10-27)
  • Windows XP SP3 32-bit. Tested by: phoenix (10/23/2009)
  • Windows XP SP2 32-bit. Tested by: vmi (01/19/2012)
  • Windows 7 Home Premium 32-bit. Tested by: azovsky (06/29/2010)
  • Windows 7 Enterprise 64-bit. Tested by: kurkuma (02/07/2011)
  • Windows 8 Professional 64-bit. Tested by: pvasili (10/07/201.)

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Although this is elaborated on the issue resolution - it should be clarified here also. The PATH environment variable should be assigned by going to My Computer > Right-click any blank area inside window > Properties > Advanced tab > Environment Variables > System Variables > select PATH & edit as described.

This instruction is for Windows XP SP3 32-bit.

Thank you,
Ivan

On Windows 8.1, for reasons I don't understand, drush 6.0 installed fine via the windows installer and ran from the DOS command window, but would not run from the git bash window. Only the system path was recognized. I added the PHP path to the system path, and it work. I removed it (leaving it in the user path), and it still worked. Perhaps some odd caching??

On windows XP, %* works and accept all arguments, so I'm not sure you need to put%1 %2..., although setting up this would limit you to 9 arguments...

Works on Windows 7 Home Premium 64-bit.

I tried this
drush dl cck
i get an alert saying libssl32.dll not found
It didnt work even after installin .dll file

A little variation that works for me.

1. Added path

;C:\Program Files (x86)\PHP;C:\inetpub\wwwroot\drush;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin

2. For drush.bat, keep the original. No need to change anything. Although as recommend to put the full path to php.

Drush ruless !

Due to respect to all experienced ppl, how do I copy an .exe to another .exe? I dont understand the following instruction:

Copy the file C:\Program Files\GnuWin32\bin\bsdtar.exe to C:\Program Files\GnuWin32\bin\tar.exe

???

Check out the installation video mentioned above, athttp://vimeo.com/15371661 , as it shows the process.

It looks like I also need SSH. Can't find it within gnuwin. Any clues?

Generally speaking, you don't need ssh to install drush on windows on a personal development environment such as your laptop. If you are trying to connect to a remote server, then you may need ssh, in which case you can either use PuTTYor Cygwin. You can see more information here.

If you are trying to follow these instructions on a server, you might run into a few problems because you probably won't have the permissions to install the gnuwin32 programs or alter the path variables. You'll have to talk to your hosting provider.

$ drush or $drush.bat both work on Windows
I was under the impression that I had to call drush.bat on Windows but drush works fine as an alias

I've not been successful. there are some known issues but was hoping someone had a workaround. I'm at the point of building a virtual linux stack on my windows machine...

I have successfully installed drush on Win7, independently of my WAMP (http://www.wampserver.com/en/) installation (drush in its own directory outside WAMP and with a different version of php).
The layout is like this:
c:\wamp
e:\drush
e:\gnuwin32
e:\php <-- used with drush (zipped, not installed)

When using xampp on windows you may get warnings like "PHP Startup: Unable to load dynamic library (...)".

In this case look at the php.ini file (since xampp 1.7.1 in the xampp\php folder see:http://www.apachefriends.org/en/faq-xampp-windows.html#phpini).

I had to change the line 'extension_dir = "\xampp\php\ext"' to 'extension_dir = "E:\xampp\php\ext"' and do the same for browscap.

If you download the zip versions of the binary packages, do not forget to download the dependencies as well.

when I open the bat file I just get @echo off
REM See http://drupal.org/node/506448 for more information.
@php.exe "%~dp0drush.php" %*

what am i supposed to do to the bat file?

Can someone clarify Step 2? Copy to the directory? Why is it telling us to copy to the ...exe file?

it means: Copy AND RENAME the file C:\Program Files\GnuWin32\bin\bsdtar.exe to C:\Program Files\GnuWin32\bin\tar.exe

In shell scripting the copy command can also rename a file, so copying to a new filename implies renaming it.

You should learn how to use the Windows command terminal (cmd.exe) which basically uses DOS syntax. You will need to use it for Drush on Windows. There are also replacements for the default teminal, such as Console.

My path to php c:\wamp\bin\php
path to Drush c:\wamp\www\drush

I ran "drush' on cmd and get the following :
'php.exe' is not recognized as an internal or external command, operable program or batch file.
What may I have done wrong ?

Never mind. I had path to php.exe wrongly declared in drush.bat . It works now !

Hi, I've got problem with dosn't working Drush on Windows 7. I have instaled Apache+PHP+Mysql server.
When I want to start Drush I've got information about absence php_mbstring.dll library despite of it's in c:\Program Files\PHP\ext\ catalog. Although it dosn't found OCI.dll; aspell-15.dll; libcs.dll libraries.
I've got instaled Gzip; Libarchive; Wget; Tar programes. In "Control Panel > System > Advanced System Settings > Environment Variables->Path".
I have path "C:\Program Files\PHP;C:\drush;C:\Program Files\GnuWin32\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin".
In file drush.bat I've code;
"@c:\Program Files\PHP\php.exe "%~dp0drush.php" %*
@c:\Program Files\PHP\php.exe C:\drush\drush.php %1 %2 %3 %4 %5 %6 %7 %8 %9"

Try using an integrated WAMP distro - it looks like you installed Apache and PHP and MySQL separately and may have configuration problems.

I use Xampp for Windows

There is also a Dev Desktop by Acquia that includes the *AMP stack and Drupal

I am using Xampp and I can confirm that Drush is working on Windows 7. My command line looks like this with PHP included in xampp. Notice that I am not using the C:/Program Files/ directory at all, it's in the root:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

c:\xampp\htdocs\drupal71>drush status

c:\xampp\htdocs\drupal71>c:\xampp\php\php.exe "C:\drush\drush.php" status

Drupal version                :  7.0
Site URI                      :  http://default
Database driver               :  mysql
Database hostname             :  127.0.0.1
Database username             :  drupal70
Database name                 :  d70
Database                      :  Connected
Drupal bootstrap              :  Successful
Drupal user                   :  Anonymous
Default theme                 :  bartik
Administration theme          :  seven
PHP configuration             :  C:\xampp\php\php.ini
Drush version                 :  4.0-dev
Drush configuration           :
Drupal root                   :  C:/xampp/htdocs/drupal71
Site path                     :  sites/default
File directory path           :  sites/default/files
Private file directory path   :  /backup_migrate

c:\xampp\htdocs\drupal71>

Step 3

Using Xampp installed at c:\xampp the PATH to PHP is c:\xampp\php

Step 4

In drush.bat I had to change

@php.exe "%~dp0drush.php" %*

to

@php.exe "%~dp0drush.php" %1 %2 %3 %4 %5 %6 %7 %8 %9

I had to create C:\tmp to avoid "Fail to open stream" errors.

Got it working with above instructions and a minor tweak for the batch file:
http://drupal.org/node/506448#comment-4585172

succesfull on Win 7 Professional, 64bit, Acquia stack (6.20)

Albert Skibinski - Merge

If using Git and Drush isn't finding it, add the path to Git/bin to your Path environment variable; e.g. ;c:\Program Files (x86)\Git\bin. Then restart whatever shell you're using (i.e. cygwin).

Works on Windows 7 Professional 32-bit.

Thanks!

Where are the instructions for applying a patch to drush for windows?

I use the Eclipse IDE for patches, applying and creating them.

I've tried other Windows patch tools, but Eclipse just does it. In fact, that is about all I use Eclipse for these days.

Eclipse Helios had a distro for PHP developers

The current release Indigo doesn't; maybe they just rolled it into the Classic distro?

I also used the Subclipse plugin to integrate my Eclipse projects with Subversion.

It's also pretty easy to create and apply patches with Git and it's the method to use for Drupal projects

This procedure also work on Windows 7 Professionals 64 bit.

My PATH C:\drush\;C:\Program Files (x86)\GnuWin32\bin;C:\xampp\php

Thanks

Life is too short, love it, be happy, don't waste your time with sorrow, anger and upsets. :)
Drupal and web knowledge sharingPersonalize Drupal training in Singapore

C:\ProgramData\Propeople\Drush/lib/drush-library-1301704602.tar.gz
using the gzip command failed.

C:\Users\lwebg>drush
Uncompressing C:\drush/lib/drush-library-230983746.tar.gz using the [error]

gzip command failed.

I get this error and the gzip package is installed.

You can use another Windows unzip app like 7zip to decompress the archive

but you might want to see what else is wrong with your setup ;)

I know I am in the minority, but does anyone have any information on Windows 8 and Drush?

Cheers.

Please share the information if anyone have idea about how to install Drush on Windows 8 machine.

Thanks

Alok Bhatt
(+91 95030 24643)

Do anybody have some info about installing Drush on Win 8.1 pro?

Although it is mentioned in top line that this tutorial was updated 16th April, the very first line in installating the hard way, Drush download url has not been corrected.
Kindly update that to GITHUB from drupal.org https://github.com/drush-ops/drush

Best Website Designs & SEO
http://howzthatim.com

 

  1. Drush Windows Installer - drush.ws.

 

 

The drush windows installer site is offline and does also not seem to be hosted on the git hub drush ops site.

Is there a URL to download this?

>>>>>> found it >>>>>>>

https://github.com/drush-ops/drush/commit/0988485788c160f1c4c3c485625585...

Hi,

I have follow all steps but again show this error blow :-

The drush command 'status' could not be found, Run 'drush cache-clear drush' to clear the commandfile cache if you have installed new extensions. function and the attempt to download this file automatically failed.To continue you will need to download the 1.1.3 package from website

For my windows 8 I used the exe file to install Drush. Then I set the path like cited above in
control panel>system and security>system>advanced system settings> environment variables
And it was done. Had a few issue with a step by step installation, but the exe did the trick!
Now it's working fine Apart from a migrate thing havent quite figured out yet, but I guess that's just me ;)

NanaBrown

来自 https://www.drupal.org/node/594744

普通分类: