提供:すだちWiki
移動先: 案内検索

Apacheのエラーページをカスタマイズ

エラーページをカスタマイズします。

エラードキュメントルート所有者変更

※CentOS6,5の場合

[root@host2 ~]# chown sysop. /var/www/error ← ドキュメントルート所有者を変更

[root@host2 ~]# ll /var/www/ ← ドキュメントルート所有者変更確認
合計 24
drwxr-xr-x.  2 root  root    4096  8月 14 02:30 2013 cgi-bin
drwxr-xr-x.  3 sysop sysop   4096  8月 15 03:46 2013 error
drwxr-xr-x. 13 sysop sysop   4096 10月 13 16:53 2013 html
drwxr-xr-x.  3 root  root    4096  8月 15 03:46 2013 icons

変更

※CentOS 7,6,5の場合

[root@host2 ~]# vi /etc/httpd/conf/httpd.conf

#    ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
#    ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
#    ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
     ErrorDocument 401 /error/401.html ← 追加
     ErrorDocument 403 /error/403.html ← 追加
     ErrorDocument 404 /error/404.html ← 追加
     ErrorDocument 500 /error/500.html ← 追加
</IfModule>
</IfModule>

Webサーバー再起動

Webサーバー再起動して設定変更を反映します。

※CentOS7の場合

[root@host3 ~]# systemctl restart httpd

※CentOS6,5の場合

[root@host3 ~]# /etc/rc.d/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]