Question

My site is developed in Drupal 7. Recently I have put my site to maintenance mode. And now I need to put this site back to live.

Unfortunately I am not able to login as admin and 'Go Online'(Because of some modifications in the user login form). I have also tried to update the 'site_offline' variable by database query. But this also did not work. To my surprise, there was no variable like 'site_offline' in db. Why is this so?

Can anybody help to get this issue solved? Any help or suggestions will be a greatly appreciated.

Was it helpful?

Solution 5

Finally I have found a workaround for this problem. I logged in to the application by admin programmatically using below code,

global $user;
$user = user_load(1);
drupal_session_regenerate();
drupal_goto('user');

Reference

After getting logged in, I changed the maintenance configuration from admin/config/development/maintenance.

UPDATE

Please make sure to delete the above code once the site is set back from maintenance mode. Otherwise this will give administration access to any user visiting the website.

OTHER TIPS

I also faced the same issue, and I add following statement to the end of the settings.php file. And it worked.

        $conf['maintenance_mode'] = 0;

Source : https://www.drupal.org/node/276457#comment-9364023

There is no need to do changes in database.

Just add $conf['maintenance_mode'] = 0; to your settings.php file. This will override the default settings.

If you log yourself out and can't get back in, just add /?q=user after your website address and you'll be back to the user login page.

If you have access to the crush shell for the site, you can simply run:

# from drupal root (/path/to/index.php)
drush vset maintenance_mode 0;
drush c all;

If not, or if that doesn't work, update the "maintenance_mode" property in the variable table to "i:0;" (not 0 because drupal stores and parses these settings as long blob).

#sql statement
UPDATE `variable` SET `value` = 'i:0;' WHERE `name` = 'maintenance_mode';

Note: if you only have access to the database, you will likely need to clear out all the cache tables manually.

I found that that the solution was to simply navigate to yoursitename/user/login

simply log in as the site admin and turn off maintenance mode.

Its a lot simpler than messing about with the code suggestions above...

The annoying thing is that this "simple" fix took me an hour of Googling and going down various rabbit holes suggested on other forums.

Perhaps we (as developers) should take some time to learn how to use the products we are asked to support?

You can also put it manually out of maintenance mode by editing index.php and setting the variable "maintenance_mode"

<?php
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/


/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());


require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
variable_set('maintenance_mode', 0);
menu_execute_active_handler();

source: https://www.drupal.org/node/2072055#comment-7784641

I recommend the Drupal documentation:

It basically states what Alexander Farber posted, but indicates also that once you are logged on, you navigate to the Administration page, as per Drupal version, go to these links:

  • Drupal 4: administer » settings (admin/settings)
  • Drupal 5&6: Administer » Site configuration » Site maintenance (admin/settings/site-maintenance).
  • Drupal 7: Administration » Configuration » Development » Maintenance Mode: remove the check mark on box "Put site into maintenance mode"

It might sound crazy but in some Apache versions, default file for web server to open is .html and there is a index.html in Drupal 7 root directory and its content is :

Website is Under Construction ....

so just rename that file to something other than index, then your web server will opens index.php .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top