A WordPress site can be set to maintenance mode either directly with a WP-CLI command or by using a separate maintenance plugin.
WP-CLI
WP-CLI's command wp maintenance-mode
creates .maintanance
file to the root of the WordPress installation.
wp maintenance-mode activate
Enabling Maintenance mode...
Success: Activated Maintenance mode.
The file sets WordPress installation to maintenance mode, during which you can not access the WordPress page through a browser.
You can end the maintenance mode by using command wp maintenance-mode deactivate. This removes the .maintenance file
.
wp maintenance-mode deactivate
Disabling Maintenance mode...
Success: Deactivated Maintenance mode.
Maintenance Plugin
You can also set the page to a maintenance mode using a maintenance plugin.
Maintenance is easy to easy and efficient plugin. After installing the plugin you can activate a maintenance mode. From settings you can adjust the look of the maintenance mode. Once in the maintenance mode, in the right of the screen there is a lock icon that you can use to login in to the website.
If necessary, empty the WordPress cache to enter maintenance mode immediately.