How to put magento in maintenance
Asked Answered
C

13

17

Is it possible to put a magento site under an maintenance flag so that visitors will get a message that the site is under construction? I can't find this setting in the admin area.

Another solution will also be welcome.

Any help would be appreciated.

Thank you.

Connected answered 17/11, 2010 at 2:59 Comment(0)
F
24

I use this often. http://inchoo.net/ecommerce/magento/maintenance-mode-in-magento/

The important part is:

Open: index.php in root and above line 57 add (remembering to edit the ‘allowed’ array to contain the IP’s you want to be able to access the site);

$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('1.1.1.1','2.2.2.2'); // these are the IP's that are allowed to view the site.

then change the line

if (file_exists($maintenanceFile)) {

to

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
Frutescent answered 17/11, 2010 at 4:28 Comment(4)
Thanks. I have put the maintenance.flag in the main directory. The only problem is that it shows the default Magento template with the error. Any idea how I can get this error message in my own theme design?Connected
Look in the /errors/ directory. You can either edit the default skin that is there or create your own and enable it in a local.xml file. There is no way to use your existing theme for error pages which is a good thing, you might be working on that very theme which you don't want people to see.Frutescent
try to use this magentocommerce.com/magento-connect/… it is also support maintenance page with your design theme.Largo
@JonSurrell you are correct. I wasn't following SO guidelines. In my defense this was one of my earliest answers.Frutescent
A
30

To enable maintenance mode in Magento, just create empty maintenance.flag file in the root of your Magento store.

Acrimony answered 1/4, 2012 at 3:13 Comment(0)
F
24

I use this often. http://inchoo.net/ecommerce/magento/maintenance-mode-in-magento/

The important part is:

Open: index.php in root and above line 57 add (remembering to edit the ‘allowed’ array to contain the IP’s you want to be able to access the site);

$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('1.1.1.1','2.2.2.2'); // these are the IP's that are allowed to view the site.

then change the line

if (file_exists($maintenanceFile)) {

to

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
Frutescent answered 17/11, 2010 at 4:28 Comment(4)
Thanks. I have put the maintenance.flag in the main directory. The only problem is that it shows the default Magento template with the error. Any idea how I can get this error message in my own theme design?Connected
Look in the /errors/ directory. You can either edit the default skin that is there or create your own and enable it in a local.xml file. There is no way to use your existing theme for error pages which is a good thing, you might be working on that very theme which you don't want people to see.Frutescent
try to use this magentocommerce.com/magento-connect/… it is also support maintenance page with your design theme.Largo
@JonSurrell you are correct. I wasn't following SO guidelines. In my defense this was one of my earliest answers.Frutescent
C
11

Just add a blank file called maintenance.flag to your root.. job done

A neater solution is to use this extension.

it allow you to set the store up so that once logged into the back end you have access to the front + a few other neat features

Combatant answered 27/3, 2012 at 9:35 Comment(0)
C
6

Thats what I add to the index in order to be able to continue working from different IPs:

//EGS to show a maintenance page but be able to work
$ip = $_SERVER['REMOTE_ADDR'];

// these are the IP's that are  allowed to view the site:
$allowed = array('111.111.111.111', '222.222.222.222');

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) { 
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
Carrnan answered 23/7, 2012 at 12:59 Comment(0)
C
0

Magento has maintenance.flag support built in. Check this out from

http://www.nicksays.co.uk/2010/07/enabling-magento-maintenance-mode/

Cowgirl answered 25/1, 2012 at 22:54 Comment(2)
SPELLING ERROR! maintenance.flagParimutuel
Thanks @AndrewAtkinson, that's fixed.Aubert
O
0

These are good modules to put your magento sites into maintenance mode anytime you want. http://www.magentocommerce.com/magento-connect/store-maintenance.html

OR

If you want fun with working on the code then create maintenance.flag file which put your site into maintenance mode. And if you want to change the template of it then goto errors/default/503.phtml file. Just change the design of it.

This is a simple solution.

Outcaste answered 2/8, 2012 at 18:57 Comment(1)
SPELLING ERROR maintenance.flagParimutuel
K
0

The following would work with an apache installation (need to check with others).

You could create your own custom site under maintenance html page say index.html and place it in the root directory of your installation.

Open the .htaccess folder and rename the default page from index.php to index.html. Restart Apache. Once you are done rename the default page back to index.php.

It should work.

Kerns answered 5/9, 2012 at 20:57 Comment(0)
I
0

You may check this article, it has info about puting store to the maintenance for several IPs and have some working examples and needed files:

http://blog.magalter.com/page/how-to-temporarily-block-magento-store-access-put-website-to-maintenance-mode

Intelsat answered 5/2, 2014 at 9:48 Comment(0)
G
0

I followed this tutorial to put my Magento store to maintenance mode, you may try as below:

  1. Create a file name maintenance.flag in your magento root directory. Contents under this file doesn’t matter, you can keep it empty.

  2. Change the maintenance file (located in magento root -> errors -> default directory) to show proper message when user visits your website. Hop this helps

Gregoire answered 4/4, 2014 at 9:32 Comment(0)
L
0

Check out this http://www.magentocommerce.com/magento-connect/all4coding-offline-maintenance-page.html it provide exactly what you are looking for. compatible with magento 1.4 - 1.8.

You can also display the maintenance page with your design theme.

Largo answered 10/4, 2014 at 1:11 Comment(0)
W
0

I followed this tutorial http://magentoexplorer.com/how-to-show-and-customize-magento-maintenance-mode-page to enable maintenance mode page in Magento, you need to create and upload maintenance.flag file to Magento root folder, however there are some more step for a good Maintenance mode like.

  1. Add exception during maintenance (allow specific IP to visit your site during maintenance). In index.php, add these lines

    $ip = $_SERVER['REMOTE_ADDR']; $allowed = array('x.x.x.x','y.y.y.y');

  2. Edit maintenance mode page Edit maintenance mode page in /errors/default/503.phtml Remove wrap in /errors/default/page.phtml

Hope this helps.

Wynny answered 26/8, 2016 at 10:22 Comment(0)
E
0

If you need to put Magento in maintenance mode only in frontend, leaving admin enabled for authentication you can try these steps:

  1. Open index.php (from Magento root installation)
  2. Search for the content below (around line 63):

    if (file_exists($maintenanceFile)) {
    
  3. Replace for:

    if (file_exists($maintenanceFile) && !preg_match('/^\/(admin|index.php\/admin)/', $_SERVER['REQUEST_URI'])) {
    
  4. Create a blank file named maintenance.flag in your Magento root installation:

    $ touch maintenance.flag
    

This solution was inspired in the maintenance mode used in Opencart that uses the same behavior.

Equipotential answered 25/10, 2017 at 17:14 Comment(0)
S
-2

Create an empty maintenance.flag file in the root of your Magento store.

Surreptitious answered 4/3, 2016 at 8:53 Comment(1)
What does this add to earlier answers?Cassandry

© 2022 - 2024 — McMap. All rights reserved.