Posted by GasmanDesign on August 19, 2014 at 4:02pm
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
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"
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
Right you are :) I must be in the Drupal 6 groove this morning :-0
Sorry to hear that. :)
I just now recovered from a D6 facepalm moment of my own.
Very helpful!
Thanks for the tips!
Drush too!
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 1to take it offline, anddrush vdel site_offlineto bring it back.--
David Needham
Team Lead of Training at Datadog
Actually, I think you should use maintenance_mode
I always use
drush vset maintenance_mode 1to turn on maintenance mode &drush vset maintenance_mode 0to 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
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