apache再起動をかけたら下記エラーが上がって来ちゃった。。。
[root@centos ~]# /etc/init.d/httpd restart
httpd を停止中: [失敗]
httpd を起動中: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[失敗]
エラー内容の通り、80ポートが使われてる。。。
apacheデーモン停止が失敗したからかな。。。
とりあえずapacheの使用状況確認
[root@centos ~]# /usr/sbin/lsof -i | grep http
perl 15341 apache 3u IPv6 7396 TCP *:http (LISTEN)
perl 15341 apache 5u IPv6 7401 TCP *:https (LISTEN)
使ってること一目瞭然、後はそれを切っちゃえばOK
[root@centos ~]# kill -9 15341
[root@centos ~]# /usr/sbin/lsof -i | grep http
[root@centos ~]#
[root@centos ~]# /etc/init.d/httpd start
httpd を起動中: [ OK ]
ソースが面倒なので、yumから直接インストール
[root@centos ~]# yum -y install mod_ssl openssl
おれおれ証明書だから有効期間を適当に10年しとく
[root@centos ~]# cd /etc/pki/tls/certs
[root@centos ~]# sed -i 's/365/3650/g' Makefile
変更された箇所
/usr/bin/openssl req $(UTF8) -newkey rsa:1024 -keyout $$PEM1 -nodes -x509 -days 365 -out $$PEM2 -set_serial $(SERIAL) ; \
/usr/bin/openssl req $(UTF8) -new -key $^ -x509 -days 365 -out $@ -set_serial $(SERIAL)
/usr/bin/openssl req $(UTF8) -new -key $(KEY) -x509 -days 365 -out $(CRT) -set_serial $(SERIAL)
証明書作成
[root@centos ~]# make oreore.crt
Enter pass phrase: ⇒ 任意文字列(※パスワード)入力
Verifying - Enter pass phrase: ⇒ 任意文字列(※パスワード)入力
Enter pass phrase for oreore.key: ⇒ 任意文字列(※パスワード)入力
Country Name (2 letter code) [GB]: JP
State or Province Name (full name) [Berkshire]: Tokyo
Locality Name (eg, city) [Newbury]: Chuo-ku
Organization Name (eg, company) [My Company Ltd]: hogehoge Co,Ltd.
Organizational Unit Name (eg, section) []: admin
Common Name (eg, your name or your server's hostname) []: www.hogehoge.jp
Email Address []:admin@hogehoge.jp
パスワード毎度聞かれなよう、秘密鍵からパスワード削除
[root@centos ~]# openssl rsa -in oreore.key -out oreore.key
Enter pass phrase for server.key: ⇒ 任意文字列(※パスワード)入力
crt設定値確認コマンド※どっちか
[root@centos ~]# openssl asn1parse -in oreore.crt
[root@centos ~]# openssl x509 -noout -text -in oreore.crt
SSL関連設定見直し
[root@centos ~]# vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/httpd/conf/ssl.crt/server-dsa.crt
↓
SSLCertificateFile /etc/pki/tls/certs/oreore.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server-dsa.key
↓
SSLCertificateKeyFile /etc/pki/tls/certs/oreore.key
#DocumentRoot "/var/www/html"
↓
DocumentRoot "/var/www/html"
設定反映apacheリロード
[root@centos ~]# /etc/init.d/httpd reload
ブラウザからhttps://www.hogehoge.jpへアクセスし、俺俺証明書を確認。。。
以上
・パッケージ確認
[root@centos ~]# rpm -qa | grep http*
・なければインストール(※ここはyumを使用)
[root@centos ~]# yum -y install httpd httpd-devel
・設定ファイル修正
[root@centos ~]# vi /etc/httpd/conf/httpd.conf
※エラーページ等にOSバージョンを表示しない
ServerTokens OS
↓
ServerTokens Prod
ServerAdmin root@localhost
↓
ServerAdmin ***@*****
#ServerName www.example.com:80
↓
ServerName ドメイン名:80
Options Indexes FollowSymLinks
↓
Options Includes ExecCGI FollowSymLinks
※.htaccessの許可
<Directory />
・・・
AllowOverride None
↓
AllowOverride All
</Directory>
<Directory "/var/www/html">
・・・
AllowOverride None
↓
AllowOverride All
</Directory>
※エラーページ等にapacheバージョンを表示しない
ServerSignature On
↓
ServerSignature Off
AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8
※CGIスクリプトに.plを追加
#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl
・アイコンのファイル一覧を表示しない
<Directory "/var/www/icons">
Options Indexes MultiViews
↓
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
・apache起動
[root@centos ~]# /etc/init.d/httpd start
[root@centos ~]# chkconfig httpd on
[root@centos ~]# chkconfig --list httpd
・アクセステスト
[root@centos ~]# echo test >> /var/www/html/index.html
※ブラウザで動作確認し、「test」が表示されればOK。
最近のコメント