ApacheのupdateによるSSLの設定変更
現象
apacheをupdateした場合にhttpが起動していなかった
原因
Apacheをupdateした場合、SSl.confが自動でインストールされて、
ポート重複エラーでapacheが停止。
そのため、SSL通信を複数のバーチャルホストで行う場合に必要な設定をする、
または、不要であればssl.confを読み込まないようにしてapacheの再起動が必要。
状況確認
[root](VM-GUEST)# /etc/init.d/httpd status
httpd は停止しています
[root](VM-GUEST)# /etc/init.d/httpd start
httpd を起動中:
[Thu Aug 18 12:58:39 2016] [warn] module ssl_module is already loaded, skipping[Thu Aug 18 12:58:39 2016] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
[Thu Aug 18 12:58:39 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs
[失敗]
warningの種類
※ほぼ1IPしかないサーバーで複数のSSLを設定すると出力されるエラー
[warn] module ssl_module is already loaded, skipping
sslのモジュールが既に読み込まれてるから、再度読みこむけどスキップするね
→/etc/httopd/conf/ssl.conf(今回インストールされた)と/etc/httpd/conf.d/XXX_ssl.conf(事前に読み込んでいたsslのconf)
[warn] _default_ VirtualHost overlap on port 443, the first has precedence
defaultに設定したバーチャルホスト(ssl.conf側)と443 ポートが重複してるよ
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
同上。既に使用されているので、/etc/httpd/conf.d/XXX_ssl.confで定義した「0.0.0.0:443」が使用できないよ
[warn] NameVirtualHost *:80 has no VirtualHosts
名前ベースのバーチャルホストの使用宣言がないよ
一括でこの警告を除く的確な方法
不要であればApacheのupdateでインストールされたssl.confを読み込まないように設定。
リネームがおすすめ。
[root](VM-GUEST)# mv /etc/httpd/conf/ssl.conf /etc/httpd/conf/ssl.conf_org
■シンタックス確認
※conf修正後は必ずシンタックスの確認が必要
[root](VM-GUEST)# /etc/init.d/httpd configtest
■状態確認
[root](VM-GUEST)# /etc/init.d/httpd status
httpd は停止しています
■Apache再起動
[root](VM-GUEST)# /etc/init.d/httpd graceful
warningを一つずつつぶしていく場合
[warn] _default_ VirtualHost overlap on port 443, the first has precedence
※下記エラーも一緒につぶせる
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
■Portの確認
[root](VM-GUEST)# grep -n Listen /etc/httpd/conf*/*.conf
/etc/httpd/conf.d/ssl.conf:19:Listen 443
/etc/httpd/conf/XXX_ssl.conf:2:Listen 0.0.0.0:443
→Listen 443の記述が2か所あった
※grp -nで行数つきで検索できる
■ssl.confの修正
/etc/httpd/conf.d/ssl.conf
■バックアップ取得
[root](VM-GUEST)# cp -p ssl.conf ssl.conf_20160818
■修正箇所
1.Portをふさぐ
#Apacheのupdateに伴うSSLの設定変更(2016.08.18)
#Listen 443
2.
■シンタックス確認
※conf修正後は必ずシンタックスの確認が必要
[root](VM-GUEST)# vi /etc/httpd/conf.d/ssl.conf
[root](VM-GUEST)# apachectl configtest
[Thu Aug 18 13:38:27 2016] [warn] module ssl_module is already loaded, skipping
[Thu Aug 18 13:38:27 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
Syntax OK
■Apacheの再起動
[root](VM-GUEST)# /etc/init.d/httpd status
httpd は停止しています
[root](VM-GUEST)# /etc/init.d/httpd start
httpd を起動中:
[Thu Aug 18 13:47:42 2016] [warn] module ssl_module is already loaded, skipping
[Thu Aug 18 13:47:42 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
[ OK ]
[root](VM-GUEST)# /etc/init.d/httpd status
httpd (pid 5023) を実行中...
[warn] NameVirtualHost *:80 has no VirtualHosts
重複で宣言しているよ、宣言ないよなどこちらは色々な理由があるのですが、今回は、
名前ベースのバーチャルホストの使用宣言があうけど実際にバーチャルホストtagの記載ないよ
使用宣言している箇所を検索
[root](VM-GUEST)# grep -n NameVirtualHost /etc/httpd/conf*/*.conf
出てきた内容の箇所をコメントアウトし、
シンタックス確認、Apacheの再起動して修正完了。
■参考になるサイト
このブログへのコメントは muragonにログインするか、
SNSアカウントを使用してください。