Moodle 2.6: Cannot access site as admin because of maintenance mode probs

Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -
Number of replies: 13

I'm running Moodle 2.6.11. Here's the thing:

(1) I enabled Maintenance Mode via the Server settings. And it worked. I got the appropriate screen.

(2) BUT ... there was no login displayed for site admins in the top RH corner of the screen. I understood there would be.

(3) So, I followed a forum suggestion and edited the config.php file to include the following line: $CFG->maintenance-enabled=0

(4) Then I logged in as admin, returned to Server settings, and discovered that maintenance had been disabled (with a comment that it was set in config.php).

(5) I then returned to config.php and commented out the $CFG line, as suggested.

(6) Then all hell broke loose! When I returned to the site, all I got was the error message: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

And that's where things remain. I am totally locked out. I've checked the data root info in config.php, and on my server, and it's correct. So too are all my file permissions.

Help!


Average of ratings: -
In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Ken Task -
Picture of Particularly helpful Moodlers

Sounds like something may have happened when editing the config.php file the last time.

What did you use to edit config.php?  Hope a true text editor.

Where did you place the $CFG->maintenance-enabled=0 and did it include a ';' at the end?

What characters did you use to comment out the line? Slashes such as //

Also, if you've upgraded to the 2.6 from older versions of Moodle, check the top of the config.php-dist file vs the top of your working config.php file.

In the config.php-dist file there should be these lines (after the comments):

unset($CFG);  // Ignore this line
global $CFG;  // This is necessary here for PHPUnit execution
$CFG = new stdClass();

Are those lines present in config.php file?

Just don't panic ... it might seem like 'all hell', but it really should be minor.  Editing the config.php file shouldn't erase moodledata and have never heard of it doing so!

Double check the config.php file ... every line that contains a $CFG-->variable and it's value should end with a ';'.  Pay attention to every 'controlling' character, comments, ticks (single quotes) on either side of variable, etc..  Especially on lines before dataroot or after.

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Ken

In answer to your points 1-4: yes, yes, yes, yes.

Point 5: No this is not an upgrade; it is a new, successful installation of 2.6 which was working perfectly before this maintenance glitch occurred.

Point 6: Yes, those 3 lines are in config.php-dist, and in all other respects config.php looks good to me. I have attached the current config.php file, with PRIVATE data hidden.

So, what do you suggest I do next?

Adrian



In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Ken Task -
Picture of Particularly helpful Moodlers

Well, your config file looks ok.

Like I said before ... what you did has absolutely NOTHING to do with moodledata and that error reported.

Think I'd try purging caches by doing directly to the URL:

http://yourserver/admin/purgecaches.php

... both on server and in browser and in browser remove cookies too.

If you edited the  config.php file you might actually have command line access?

cd moodlecode/admin/cli/

php maintenance.php --disable [ENTER]

Have anything in apache error logs?

Next step is to run on debugging and try to get to some area by direct URL.

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Well, that did the trick. I purged the caches, and now I have the maintenance page back again. But still no sign of any login block for admins. What next?

Adrian

In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
From any browser http://yoursite/login/.
In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Ken Task -
Picture of Particularly helpful Moodlers

+1 to what Visvanath posted.

And a note: in your version of Moodle, setting maintenance mode had an issue in that it (supposedly) locked ALL out (providing no link to login) of logging onto Moodle - including those that were admins.

In the command line version of maintenance mode it shows this:

--enable              Enable CLI maintenance mode
--enablelater=MINUTES Number of minutes before entering CLI maintenance mode
--enableold           Enable legacy half-maintenance mode
--disable             Disable maintenance mode

IF the first one used, then one gets behavior you are experiencing now.

2nd one is a timer till Moodle sets maintenance mode

3rd the old behavior of still allowing users to login but they cannot do anything.

In the Moodle UI (not command line) one is not presented with those options.  It's only the first - on.

'spirit of sharing', Ken



In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Nope. Doesn't work. When I go to the suggested URL (http://mysite.com/login/), I still get the maintenance page with no admin login capability. I've tried clearing the caches again, but that doesn't help.

Adrian

In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, try http://yoursite/admin/

I have a sandbox 26 and just tried that.  Does work.  Version is: 2.6.11+ (Build: 20150619)

As far as being simpler ... depends upon how much access you have to the system and if you are careful or not.  All web server setups have a variable for 'default' page ... that normally is defined as  index.html (default.htm on Winders) on a system that doesn't run any thing PHP.  When PHP is installed, then index.php is added.   If in the config of the 'default page'  for apache one list index.html then index.php it will serve out in that order.   For Moodle code, one could drop a index.html in a folder and that's what would be served out.   But, that would NOT prevent anyone from using index.php with browser.

One could hide the index.php via command line:

From directory of Moodle code:

mv index.php .index.php

cp /somedirectoryoutsidemoodle/nologinnotice.html ./index.html

Then the only thing apache can find is the index.html file and no one could go directly to index.php. 

Or you could even create a special nologin.html file and when you desire to place the site in the 'maintenance' mode, one could do somthing ike this:

cp -p index.php login-save.php

cp -p nologin.html index.html

Then when done with whatever you are doing, to take it out of 'maintenance mode one does:

cp -p login-save.php index.php

rm index.html

Wouldn't really recommend doing anything like the above - just illustrating 

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Ken

http://yoursite/admin/ works like a dream. So, I'll stick with Maintenance mode for now.

Unless anything untoward happens, I hope to be able to do so until I'm ready to launch my website (next year).

All that remains is to ask you how best to disable Maintenance mode when that time comes.

Adrian

In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Colin Fraser -
Picture of Documentation writers Picture of Testers

mmm I suggest, as Ken has already told you that there was an issue with v2.6 maintenance mode, why not go up to v2.8 or v2.9? That way the issue has been resolved for you in these versions. Doing this could also give you practice in updating and upgrading your site before it goes live. It will also improve the base you are starting from. Some useful functionality is available in v2.9 that is not in v2.8 or earlier.

In reply to Adrian O'Sullivan

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Ken Task -
Picture of Particularly helpful Moodlers

'best' is really the only way ... url to /admin/

Colin is right ... version 2.6 is no longer receiving updates/fixes to code nor security updates.   While Moodle security is pretty good, one cannot run an out-of-date Moodle forever.

Since you haven't launched for use yet, might be time to upgrade to at least 2.8.

Bug fixes for general core bugs in 2.8.x will end 9 November 2015 (12 months).
Bug fixes for security issues in 2.8.x will end 9 May 2016 (18 months).

Before you contemplate upgrading, learn how to make a full backup of what you have.  A full backup consist of an archive of the code directory, the data directory, and a SQL dump of the database.

Then, before upgrading, make sure you review the docs on how to do that.

https://docs.moodle.org/28/en/Upgrading

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Colin and Ken

Unfortunately I am stuck with 2.6.11 because my sysadmin will not/cannot update the server software to the SQL/PHP versions called for by later versions of Moodle.

Never mind. Things are working well now. Thanks for your great help.

Cheers, Adrian



In reply to Ken Task

Re: Moodle 2.6: Cannot access site as admin because of maintenance mode probs

by Adrian O'Sullivan -

Wouldn't it be simpler to disable maintenance mode and use a custom index.html or index.htm maintenance page instead?

If I do that, how do I ensure that punters are taken to index.html, not to index.php? And how do I get to index.php?

Adrian