07. web サーバーに WordPress を導入する ー WordPress 構築ハンズオン ー
参考書
- Amazon Web Services 基礎からのネットワーク&サーバー構築 改訂版
- https://www.amazon.co.jp/dp/4822237443/ref=cm_sw_r_tw_dp_U_x_k3p3Cb7VX47T4
1. 実行環境の整備を行う
DB サーバーとの疎通確認をする
- 1. MySQL をインストールします。
$ sudo yum -y install mysql
補足:疎通確認には mysql コマンドを使って実際に DB サーバーにアクセスします。そのため、web サーバーにも MySQL をインストールする必要があります。
- 2. DB サーバーにアクセスして疎通確認を行います。
$ mysql -h 10.0.2.10 -u wordpress -p Enter password: ---------- Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.5.62 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
→ h オプションを付けることで他のホストにある MySQL にもアクセスすることができました。(他ホストからのアクセスを許可する設定がアクセスされる側で必要になります。)
2. WordPress をダウンロードする
web サーバーに WordPress をダウンロードします。
$ ssh -i my-key.pem ec2-user@{パブリックサブネットのインスタンスの固定パブリック IP アドレス}
$ cd ~
$ wget https://ja.wordpress.org/wordpress-4.8.2-ja.tar.gz
注意:WordPress の最新バージョンを取得してしまうと、Amazon Linux で対応できる PHP のバージョンを上回ってしまう可能性があります。リポジトリ追加など手間が生じるため、学習目的の場合、古めの WordPress をダウンロードすることをオススメします。
- 3. ダウンロードした WordPress を展開します。
$ tar xzvf wordpress-4.8.2-ja.tar.gz
sudo cp -r /wordpress/* /var/www/html
sudo chown apache:apache /var/www/html -R
→ これで、ブラウザから web サーバーにアクセスすると WordPress の初期設定画面が表示されます。(以後の説明は割愛します。)