Drush 的第七个版本可以用在 Drupal 7 跟 Drupal 8 上,它是一个命令行工具。用下面的步骤去安装 Drush :

git clone https://github.com/drush-ops/drush.git /usr/local/src/drush

把在 Github 上的 Drush 克隆一份到本地的 /usr/local/src/drush 这个目录的下面。然后进入到这个目录:

cd /usr/local/src/drush

执行 composer install 去安装 Drush 所依赖的东西,可能会提示输入你在 github 上的用户名与密码::

composer install

会返回类似下面的这些内容:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing d11wtq/boris (v1.0.8)
    Downloading: connection...
Could not fetch https://api.github.com/repos/d11wtq/boris/zipball/125dd4e5752639af7678a22ea597115646d89c6e, enter your GitHub credentials to go over the API rate limit
The credentials will be swapped for an OAuth token stored in /root/.composer/auth.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: wanghao8080
Password: 
Token successfully created
    Downloading: 100%         

- Installing pear/console_table (1.2.1) Downloading: 100%

- Installing phpunit/php-token-stream (1.3.0) Downloading: 100%

...

pear/console_table suggests installing pear/Console_Color2 (>=0.1.2) phpunit/phpunit-mock-objects suggests installing ext-soap (*) phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1) phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) Generating autoload files 成功以后,在环境变量的目录下面创建一个 drush 的快捷方式,可以使用 ln -s  去做这件事,像这样:

ln -s /usr/local/src/drush/drush /usr/bin/drush

意思就是为 /usr/local/src/drush/drush 创建一个快捷方式,放到 /usr/bin/drush  这里。现在你应该可以在系统的任何地方使用 drush 命令了:

drush help

Drush 的文档:http://docs.drush.org/en/master/

Recent Posts