三蔵開発メモ

Web開発やインフラ関連のメモを共有します

apacheでつくる503メンテページ

環境:AmazonLinux(CentOS6でも下記やり方できます)
すべてrootユーザーで作業

apacheインストール

sudo yum install httpd

メンテナンスページ作成

vi /var/www/html/maintenance.html
-------------------
now maintenance
-------------------

mod_rewrite.htaccess許可

vi /etc/httpd/conf/httpd.conf
-------------------------------------------------
<Directory "/var/www/html">

Options -Indexes FollowSymLinks

AllowOverride All
Order allow,deny
Allow from all

</Directory>

LoadModule rewrite_module modules/mod_rewrite.so
-------------------------------------------------

.htaccess設定

vi /var/www/html/.htaccess
-------------------------------------------------
ErrorDocument 503 /maintenance.html

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/maintenance.html
#RewriteCond %{REMOTE_ADDR} =IPアドレス
RewriteRule ^.*$ - [R=503,L]
-------------------------------------------------
sudo service httpd start
sudo chkconfig httpd on

IPアドレスにアクセスして、メンテナンスページが表示されて、503が返されていればOK