Maintenance mode using server files?

Events happening in the community are now at Drupal community events on www.drupal.org.
GasmanDesign's picture

Question: Is there an easy way in Cpanel or within a Drupal file on the server to temporarily take your Drupal 7 site offline and then turn it back on?

I can't use the maintenance mode in the Drupal admin, it needs to be done using the server files.

Any advice would be appreciated.

Cheers,
Corey

Comments

If you have access to a MySQL

keithm's picture

administrative interface (e.g., phpMyAdmin) you can run

update variable set site_offline = 1 where name = 'site_offline'

Set it back to 0 to bring back online.

In Drupal 7, the variable would be "maintenance_mode"

les lim's picture

instead of "site_offline".

You can also add a conf override in your settings.php file, if it has to be through a server file:

<?php
$conf
['maintenance_mode'] = TRUE;
?>

Remove or comment the line and clear caches to put the site back online.

Right you are :) I must be in

keithm's picture

Right you are :) I must be in the Drupal 6 groove this morning :-0

Sorry to hear that. :)

les lim's picture

I just now recovered from a D6 facepalm moment of my own.

Very helpful!

wylbur's picture

Thanks for the tips!

Drush too!

davidneedham's picture

This may not be exactly what the OP was asking for, but for the same of having this all in one place, you can also do this via drush. Just run drush vset site_offline 1 to take it offline, and drush vdel site_offline to bring it back.

--
David Needham
Team Lead of Training at Datadog

Actually, I think you should use maintenance_mode

jackprobst's picture

I always use drush vset maintenance_mode 1 to turn on maintenance mode & drush vset maintenance_mode 0 to turn maintenance mode off. Looks like site_offline was the old variable that got added to be supported at some point (https://www.drupal.org/node/1612252).

https://api.drupal.org/api/drupal/install.php/constant/MAINTENANCE_MODE/7

Ah, totally right

davidneedham's picture

Looks like I fell into the same D6 trap as the others. At least this post now has info for both D6 and D7! ;-)

--
David Needham
Team Lead of Training at Datadog

Twin Cities

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: