#author("2018-11-15T12:24:02+00:00","","")
#author("2018-11-15T12:30:58+00:00","","")
[[AWSメモ]] >
* EC2にApacheをインストール [#s77563ba]
#setlinebreak(on);

ここでは以下の作業を行う。
- EC2(Amazon Linux 2)に apache をインストール
- Apache を 独自ドメインのサブドメイン名で https アクセスできるように設定

** apacheインストール [#o3ca8f4e]
#myterm2(){{
sudo yum -y install httpd
sudo service httpd start
}}

** ssl/tls設定 [#c889cc5e]
** 自動起動の設定 [#t03b784c]
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

sudo systemctl start httpd
sudo systemctl enable httpd

#myterm2(){{
sudo systemctl start httpd && sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
}}

** mod_sslインストール [#gb313f9d]
#myterm2(){{
sudo yum update -y
sudo yum install -y mod_ssl
}}

sudo sh -c "openssl genrsa 2048 > /etc/httpd/conf/aws.magata.net-server.key"
sudo sh -c "openssl req -new -key /etc/httpd/conf/aws.magata.net-server.key > /etc/httpd/conf/aws.magata.net-server.csr"
openssl x509 -req -signkey /etc/httpd/conf/aws.magata.net-server.key < /etc/httpd/conf/aws.magata.net-server.csr > aws.magata.net-server.crt
sudo mv aws.magata.net-server.crt /etc/httpd/conf/
** 自己証明書の作成 [#f30f29a3]
#myterm2(){{
# サーバ鍵の作成
sudo sh -c "openssl genrsa 2048 > /etc/httpd/conf/sample.hogehoge.com-server.key"

# 証明書要求の作成
sudo sh -c "openssl req -new -key /etc/httpd/conf/sample.hogehoge.com-server.key > /etc/httpd/conf/sample.hogehoge.com-server.csr"

# 自己署名して証明書を作成
openssl x509 -req -signkey /etc/httpd/conf/sample.hogehoge.com-server.key < /etc/httpd/conf/sample.hogehoge.com-server.csr > sample.hogehoge.com-server.crt
sudo mv sample.hogehoge.com-server.crt /etc/httpd/conf/
}}

** 作成した証明書をapacheの設定ファイルに記述 [#ldb32c55]
#myterm2(){{
sudo vim /etc/httpd/conf.d/ssl.conf
-------------
SSLCertificateFile /etc/httpd/conf/aws.magata.net-server.crt
SSLCertificateKeyFile /etc/httpd/conf/aws.magata.net-server.key
-------------
}}

#mycode2(){{
SSLCertificateFile /etc/httpd/conf/sample.hogehoge.com-server.crt
SSLCertificateKeyFile /etc/httpd/conf/sample.hogehoge.com-server.key
}}

** 再起動 [#zd65c2a0]
#myterm2(){{
sudo service httpd restart
}}



トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS