是否可以使用 Drush 使 Drupal 站点离线?
是否可以使用 Drush 使 Drupal 站点离线?
Is it possible to take a Drupal site offline using Drush?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以使用 Drush 使 Drupal 站点离线?
Is it possible to take a Drupal site offline using Drush?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
是的。
drush vset site_offline 1
将其设置为离线,然后drush vdel site_offline
将其恢复。或者,您可以在 drupal.org 上查看我的维护文件模块,如果出现以下情况,该模块会将您的站点设置为离线状态:它在目录中查找特定文件。
Yep.
drush vset site_offline 1
will set it offline, thendrush 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.
以防万一有人需要使用 Drupal 7 执行此操作,命令如下:
它还有助于在每个命令后添加一点
drush cc all
,以确保用户即时看到更改。Just in case anyone needs to do this with Drupal 7, the commands are:
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 的解决方案是最好的。我们正在运行一个非常大的多站点 drupal 安装,有数百个站点。通过 drush 使它们脱机需要每个站点几秒钟的时间,这是不可接受的。使站点脱机的最快方法是通过重命名 settings.php 文件来中断数据库连接。然后只需分配一个默认主题,该主题具有不需要数据库的基本模板,例如“站点离线”或其他内容。升级后,您只需修复 settings.php 文件即可。
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.
在 D7 上使用站点别名:
With a site alias on D7:
其实很简单,只需将维护模式变量设置为1(0恢复默认值):
It's quite easy in fact, simply set the variable of maintenance mode to 1 (0 to restore default value):
德鲁帕尔 6
德鲁帕尔 7
Drupal 6
Drupal 7