apache maintanance

Create a file called maintenance.conf with the following in it:

#RewriteEngine On
#RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
#RewriteCond %{REQUEST_FILENAME} !/maintenance.html
#RewriteRule ^.*$    /maintenance.html [L]

Then setup your vhosts like:

<VirtualHost *>
  ServerAdmin admin@website.com
  DocumentRoot /var/www/website
  ServerName  website.com
  ServerAlias www.website.com      

  Include conf/maintenance.conf
</VirtualHost>

Then when you want to enable maintenance mode, just uncomment those lines in maintenance.conf and restart apache.

Alternatively you could make maintenace.conf.disabled and maintenace.conf.enabled. Then create a symbolic link for maintenance.conf to point to the enabled or disabled version of the file and bounce apache.

You could even wrap doing that in a script. One called enabled-maintence-mode.sh and disable-maintenance-mode.sh that would remove and create the symbolic links respectively and restart apache.

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir