LinuxにApache2をSSL付きでインストールする方法

1. Apacheをダウンロードする

http://httpd.apache.org

cd ~
wget http://www.eng.lsu.edu/mirrors/apache//httpd/httpd-2.2.17.tar.gz
tar xvfz httpd-2.2.17.tar.gz

2. ApacheSSL/TLS付きでインストール

cd httpd-2.2.17
./configure --enable-ssl --enable-so
make
make install

3. SSLhttpd.confで有効にする

# vi /usr/local/apache2/conf/httpd.conf
Include conf/extra/httpd-ssl.conf

SSL設定は以下のファイルを確認

vi /usr/local/apache2/conf/extra/httpd-ssl.conf

# egrep 'server.crt|server.key' httpd-ssl.conf
SSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"

4. server.crt and server.key ファイルを作る

cd ~
openssl genrsa -des3 -out server.key 1024

ここで設定したパスワードは、後ほど使うので覚えておく.

openssl req -new -key server.key -out server.csr

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

5. server.key and server.crtをコピーする

cd ~
cp server.key /usr/local/apache2/conf/
cp server.crt /usr/local/apache2/conf/

6. apacheを起動し、SSLを確認する

/usr/local/apache2/bin/apachectl start

https://{your-ip-address}
でアクセスする.


参考
How To Install Apache 2 with SSL on Linux (with mod_ssl, openssl)
http://www.thegeekstuff.com/2011/03/install-apache2-ssl/