◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?
[root]# cd /etc/httpd/conf ←設定ディレクトリへ移動
[root]# openssl genrsa -des 1024 > server.key ←プライベート鍵作成
Generating RSA private key, 1024 bit long modulus
.++++++
..........++++++
e is 65537 (0x10001)
Enter pass phrase: ←パスフレーズ入力
Verifying - Enter pass phrase: ←再度パスフレーズ入力
[root]# openssl rsa -in server.key -out server.key ←パスフレーズ問い合わせ除去
Enter pass phrase for server.key: ←設定済みのパスフレーズ入力
writing RSA key
[root]# openssl req -new -days 365 -key server.key -out server.csr ←サイト証明書発行要求を作成
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:JP ←国名
State or Province Name (full name) [Berkshire]:KANAGAWA ←都道府県
Locality Name (eg, city) [Newbury]:HUJISAWA ←市区町村
Organization Name (eg, company) [My Company Ltd]:A ←会社名
Organizational Unit Name (eg, section) []:B ←部署名
Common Name (eg, your name or your server's hostname) []:www.example.com ←サーバ名
Email Address []:apache@example.com ←管理者のメールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: ←チャレンジパスワードは設定不要
An optional company name []: ←追加の会社名は設定不要
[root]# openssl x509 -days 365 -in server.csr -out server.crt -req -signkey server.key ←サイト証明書を作成
Signature ok
subject=/C=JP/ST=KANAGAWA/L=HUJISAWA/O=A/OU=B/CN=www.example.com/emailAddress=apache@example.com
Getting Private key
[root]# chmod 0600 server.* ←所有者のみ読み書き可能
[root]# mv server.key /etc/httpd/conf/ssl.key/ ←サーバ鍵を格納
[root]# mv server.csr /etc/httpd/conf/ssl.csr/ ←サイト証明書発行要求を格納
[root]# mv server.crt /etc/httpd/conf/ssl.crt/ ←サイト証明書を格納
[root]# vi /etc/httpd/conf/httpd.conf ←httpd設定ファイル
■以下のように編集↓■
ServerName www.example.com:80
■以下の行追加↓■
<Directory "/var/www/shtml">
AllowOverride None
Order Allow,Deny
Allow from 192.168.0.0/24
AuthType Basic
AuthName "Secure Page"
AuthUserFile /etc/httpd/conf/passwd
Require valid-user
</Directory>
[root]# vi /etc/httpd/conf.d/ssl.conf ←SSL設定
■以下のように編集↓■
DocumentRoot "/var/www/shtml"
ServerName www.example.com:443
ServerAdmin apache@example.com
[root]# htpasswd -c passwd reverie ←パスワード設定
New password: ←パスワード入力
Re-type new password: ←再度パスワード入力
Adding password for user reverie
[root]# chown -R apache * ←所有者をapacheにする
[root]# mkdir /var/www/shtml ←ディレクトリ作成
[root]# chown apache /var/www/shtml ←所有者をapacheにする
[root]# vi /var/www/shtml/secure.shtml ←テストページ作成
■適当にテスト用shtml作成■
<HTML><HEAD><TITLE>SSL TEST</TITLE></HEAD>
<BODY>SSL TEST PAGE!!!</BODY></HTML>
[root]# chmod 0600 * ←所有者のみ読み書き可能
[root]# chown apache * ←所有者をapacheにする
[root]# /etc/rc.d/init.d/httpd restart
httpdを停止中: [ OK ]
httpdを起動中: [ OK ]
←Windowsからhttps://www.example.com/secure.shtmlにアクセス
[root]# tail /var/log/httpd/ssl_access_log ←SSLアクセスログを確認
win50.example.com - - [11/Dec/2010:19:08:14 +0900] "GET /secure.shtml HTTP/1.1" 401 1304
win50.example.com - reverie [11/Dec/2010:19:08:23 +0900] "GET /secure.shtml HTTP/1.1" 200 86
COMMENT