Enable or Disable Magento 2 Maintenance Mode using CLI / Command Prompt or Files

What is the magento maintenance mode ?

When Magento is in maintenance mode, visitors see a Service Temporarily Unavailable message in their web browsers instead of the store. However, authorized IP addresses can still view the store normally.

You can enable maintenance mode using two methods.

How to enable magento maintenance mode using cli / command prompt / terminal.

Login to your server using SSH or terminal that is available to you.

change the directory to your Magento store root folder

magento-enable-maintenance-mode-cli-command-prompt

 

 

Then type in the below command and press enter to enable the maintenance mode for everyone.

bin/magento maintenance:enable

enable the maintenance mode for everyone

 

 

 

Now everyone visiting the website will see a Service Temporarily Unavailable message like below.

magento-enable-maintenance-website-viewHow to enable magento maintenance mode for everyone except few IP addresses ( or yourself)

You can also enable the maintenance mode for everyone except a few known IP addresses. This option is useful for fixing a bug on a live website.  Using this method a developer/admin can view the Magento website while other people will see a site under maintenance banner.

1st find out your computers IP address. Easiest way is to go to Chrome and search for “What is my IP address” : click here to search

what-is-my-ip-address-google-searchNow enter below command with your IP address like below .

bin/magento maintenance:enable --ip xxx.xxx.xxx.xxx

The magento website will be now under maintenance mode except for the specified IP.

magento-enable-maintenance-mode-cli-command-prompt-for-specific_ip

 

 

How to disable Magento maintenance mode using CLI / Command Prompt / Terminal

Login to your server using SSH or terminal that is available to you.

change the directory to your Magento store root folder

magento-enable-maintenance-mode-cli-command-prompt

 

 

Then type in the below command and press enter to enable the maintenance mode for everyone.

bin/magento maintenance:disable

 

 

Now the Magento “Service Temporarily Unavailable” message will be gone and the normal website will be shown.

How to enable/disable Magento maintenance mode file “maintenance.flag”

If you dont have access to SSH terminal, still you can enable magento maintenance mode by creating a blank file named “maintenance.flag” under the magento root folder using a FTP client.

To disable magento maintenance mode , delete the file “maintenance.flag” under your magento root folder.

Enable GZIP compression for Magento 2 Website on Apache/Linux to Make it Load Faster

What is GZIP ?

Gzip is a data compression algorithm capable of compressing and decompressing files quickly.

How can enabling GZIP can make a website load faster?

Websites are getting larger and carry a lot of content that can be compressed and save bandwidth during transmission over the networks. Compressing large text format files like javascript and css can save a lot of bandwidth thus improving loading speeds.

Using GZIP on a website

On Apache web server gzip compression is utilized to compress the outgoing traffic via mod_deflate. To use GZIP on a website mod_deflate must be installed, enabled and loaded with Apache. You can check of mod_deflate status by running below command in the linux terminal. >sudo httpd -M | grep deflate if mod_deflate is installed and enabled, you should see deflate_module (shared).