Enabling and Disabling Maintenance Mode
0 (0 Likes / 0 Dislikes)
Enabling and Disabling Maintenance
Mode with Joe Shindelar
In this tutorial,
we'll learn how to enable
maintenance mode, to set up
a "site under maintenance" message,
and how to disable it.
By the end of this tutorial,
you'll know how to put
your site into maintenance mode,
which allows users with
the right permissions to use the site,
while users without this permission
are presented with a message
that the site is
currently under maintenance.
Before you get started
with this tutorial,
you want to make sure that
you're familiar with the concept of
performing regular security updates,
and if you want to use Drush
to enable or disable maintenance
mode, Drush must be installed.
See the written version of this tutorial
for links to each of
these prerequisite tutorials.
First, we're going to walk through
enabling maintenance mode
using the administrative interface.
In the Manage administrative menu
navigate to Configuration.
Then under the Development section
navigate to Maintenance mode.
We can put the site
into maintenance mode
by checking the
Put site into maintenance mode box
on this form.
We can additionally specify
the information that is shown to
website visitors
when maintenance mode is enabled.
Placeholders such as @site
can be used in the message.
Let's use the text:
@site is currently under
maintenance mode.
We should be back shortly.
Thank you for your patience.
Once we're happy with the text,
we can click Save configuration.
You can verify that your site is
in maintenance mode
by accessing it from another browser,
where you are not logged in.
If for some reason
it doesn't appear to be working,
try clearing the cache
so that the settings take place.
Additionally, when you're logged in
as a user that has permission to view
the site in maintenance mode,
you should see this message,
Operating in maintenance mode,
displayed on all pages.
In order to disable maintenance
mode, we'll navigate back
to the maintenance mode
configuration page.
And, then uncheck the box
Put site into maintenance mode
and click Save configuration.
Once again, you can verify
that the site is no longer in
maintenance mode by accessing it
from another browser,
where you are not logged in.
And if the settings
don't appear to take effect,
try clearing the cache.
We can also enable or disable
maintenance mode using Drush.
At the command line, enter this command:
drush sset, for state set,
system.maintanence_mode 1
and then hit Enter.
Followed by drush cr
to rebuild the cache.
The combination of these 2 commands
will put your site
into maintenance mode.
You should then verify that the site
is indeed in maintenance mode
by visiting the site in a browser
where you are not logged in.
To disable maintenance mode,
run the Drush commands again.
This time system.maintenance_mode
should be set to zero.
Clear the cache so that
the settings take effect,
and then verify in your browser that
it is indeed no longer
in maintenance mode.
In this tutorial we learned how to use
both the administrative user interface
and the Drush command line tool
to enable and disable maintenance
mode for our site.