2.インスタンスのセットアップ(全部rootユーザーで実行)
必要なモジュールをインストール
# mysql5.6をインストール yum install mysql56 mysql56-libs mysql56-server # httpd2.4をインストール yum install httpd24 httpd24-tools # php5.6をインストール(CakePHP3を動かすのにintl、mbstringなどが必要) yum install php56 php56-intl php56-pdo php56-jsonc php56-mbstring php56-mysqlnd php56-xml # httpd2.4用のmod_sslをインストールし忘れてたのでインストール yum install mod24_ssl # httpdとmysqlの自動起動設定 chkconfig httpd on chkconfig mysqld on
MySQLを起動したところ、メモリが不足しているのか起動できませんでした。この現象についてググったところ以下の設定についての情報を見つけました。
参考:【AWS】t2.nanoのEC2インスタンスでのMySQL起動が失敗する。
MySQLの設定(my.cnf)
[mysqld] +performance_schema=off
httpdの設定(httpd.conf)
# 66行目 -User ec2-user +User ec2-user # 144行目 -Options Indexes FollowSymLinks +Options FollowSymLinks # 151行目 -AllowOverride None +AllowOverride All
httpdの設定(httpd-vhosts.conf)
httpのリクエストは全てhttpsに書き換える設定(ServersMan@VPSで設定していたものをそのままコピペ)
<VirtualHost *:80> ServerName md5.imo-tikuwa.work DocumentRoot /var/www/@@@@@/ RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] <Directory /var/www/@@@@@/> AllowOverride All Options FollowSymLinks Require all granted </Directory> </VirtualHost> <VirtualHost *:443> ServerName md5.imo-tikuwa.work DocumentRoot /var/www/@@@@@/ SSLEngine on SSLCertificateFile /etc/letsencrypt/live/imo-tikuwa.work/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/imo-tikuwa.work/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/imo-tikuwa.work/chain.pem <Directory /var/www/@@@@@/> AllowOverride All Options FollowSymLinks Require all granted </Directory> </VirtualHost>
httpdの設定(welcome.confの中身を全てコメントアウト)
#<LocationMatch "^/+$"> # Options -Indexes # ErrorDocument 403 /.noindex.html #</LocationMatch> # #<Directory /var/www/noindex> # AllowOverride None # Require all granted #</Directory> # #Alias /.noindex.html /var/www/noindex/index.html
ロケールの設定
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
certbot(letsencrypt)をインストール
# certbotをインストール curl https://dl.eff.org/certbot-auto -o /usr/bin/certbot-auto chmod 700 /usr/bin/certbot-auto # httpdが起動していない状態で以下を実行 certbot-auto --debug certbot-auto certonly --standalone -d imo-tikuwa.work -d md5.imo-tikuwa.work
「MD5の変換/逆変換ツール」のアプリケーションの展開、データベースダンプの投入、crontabの設定、ドメインのDNS変更、ssl証明書の失効等はEC2の環境構築とはあまり関係ないので省略します。