开发者

Is it possible to take a Drupal site offline using Drush?

Is it possible 开发者_开发问答to take a Drupal site offline using Drush?


Yep. drush vset site_offline 1 will set it offline, then drush vdel site_offline will bring it back.

Alternatively, you can check out my Maintenance File module on drupal.org, which will set your site to offline if it finds a specific file in the directory.


Just in case anyone needs to do this with Drupal 7, the commands are:

drush vset maintenance_mode 1 --yes   # Take site offline 
drush vset maintenance_mode 0 --yes   # Put site back online

It also helps to add a little drush cc all after each of those commands to ensure that the change appears instantaneous to users.


theunraveler's solution is the best if you're running a single site. We were running a very large multisite drupal installation, with hundreds of sites. Taking them offline that way via drush takes several seconds per site which was unacceptable. The fastest way to take a site offline is to break the db connection by for example renaming the settings.php file. Then just assign a default theme that has a basic template that doesn't require the db, saying "Site Offline" or something. After upgrading you can just repair the settings.php file and you're good to go.


With a site alias on D7:

drush @site_alias -y vset maintenance_mode 1    # Take site offline
drush @site_alias -y vset maintenance_mode 0    # Take site online


It's quite easy in fact, simply set the variable of maintenance mode to 1 (0 to restore default value):

drush vset maintenance_mode 1


Drupal 6

drush vset site_offline 1

Drupal 7

drush vset maintenance_mode 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜