This article describes how to use the Drush command-line tool to do common Drupal administrative tasks.
Drush is a tool for Drupal that enables you to do common administrative tasks and basic scripting from the command line. For example, you can back up and restore Drupal sites, install modules, and more.
To verify that Drush is installed and functioning correctly on your account, follow these steps:
Alternatively, if you installed Drupal in a subdirectory, change to that directory instead.
Type the following command:
Drush should display information about your Drupal installation that resembles the following output (specific values will vary):
Drupal version : 7.26 Site URI : http://default Database driver : mysql Database hostname : localhost Database username : user_drup502 Database name : user_drup502 Database : Connected Drupal bootstrap : Successful Drupal user : Anonymous Default theme : bartik Administration theme : seven PHP configuration : /usr/local/lib/php.ini Drush version : 5.8 Drush configuration : Drupal root : /home/username/public_html/drupal Site path : sites/default File directory path : sites/default/files Temporary file directory path : /tmp
A common Drupal administration task is module configuration. This is often done through Drupal's web administration interface. However, you can also quickly and easily work with Drupal modules on the command line.
For example, if you need to download and enable several modules, it is much quicker to do this on the command line with Drush than it is to click through the various Drupal web administration pages.
To download a Drupal module, type the following command in the directory where Drupal is installed. Replace module with the name of the module that you want to download:
drush dl module
Some Drupal modules, such as composer_manager, have additional PHP configuration requirements (for example, allow_url_fopen must be enabled). On some servers, you may receive an error message when you try to download or enable these modules. To resolve this problem, follow these steps:
To make the new settings take effect immediately, type the following command:
To enable a Drupal module that you have downloaded, follow these steps:
drush en module
To disable a Drupal module, follow these steps:
drush dis module
To check for available updates for your Drupal site, follow these steps:
Drush checks if there are updates available:
Drush makes it easy to quickly back up and restore Drupal databases. To do this, follow these steps:
drush sql-dump --result-file=db-backup.sql
Drush saves the Drupal database to the db-backup.sql file. (You can name the file anything you want.)
To restore the database backup, type the following command:
drush sql-cli < db-backup.sql
Backing up and restoring entire Drupal sites is easy with Drush. A backup includes all Drupal site files, databases, and code in one compressed file.
To do this, follow these steps:
Drush backs up and compresses the Drupal site. When Drush completes the backup, it indicates the path and filename where the backup file is located.
To restore the site backup, type the following command in the directory where Drupal is installed. Replace /path/filename.tar.gz with the complete path and name of the Drupal backup file:
drush archive-restore /path/filename.tar.gz
There are times, particularly during site development, when you may want to clear out Drupal's caches. To do this, type the following command in the directory where Drupal is installed:
drush cache-clear all
Drupal rebuilds its search index at fixed times according to a cron job schedule. However, you can instruct Drupal to immediately rebuild the search index. To do this, type the following command:
When you are prompted, type y to continue.
For more information about Drush, please visit http://drush.org.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.