|
1 |
| -# Advanced WordPress構築サンプル |
2 |
| -## 概要 |
3 |
| -実践的なWordPress環境のサンプル |
4 |
| - |
| 1 | +# Advanced WordPress Example |
| 2 | +This is the example of building high available wordpress with SLB and ECS, RDS and so on. Architecture overview is [here](https://docs.google.com/presentation/d/1pqtbiJRGc3uUm8ulhMBf4SWm2WPCCrhgUInjm9DMYdc/edit?ts=5b1df94f#slide=id.g3bf33c5b60_0_77). |
5 | 3 |
|
6 |
| -- SLBの構築 |
7 |
| - - リスナーの設定 |
8 |
| - - バックエンドサーバの設定 |
9 |
| -- ECS(WordPress用)の構築 |
10 |
| -- ECS(踏み台用)の構築 |
11 |
| - - NATサーバとしての設定 |
12 |
| - - VRouterのルーティングテーブルへの追加 |
13 |
| -- RDSの構築 |
14 |
| -- VPCの構築 |
| 4 | +1. Create VPC |
| 5 | +1. Create Vswitch |
| 6 | +1. Create Security Group and set some rules |
| 7 | +1. Create two ECS instances for wordpress application in Vswitch |
| 8 | +1. Create one ECS instance for bastion server in Vswitch |
| 9 | +1. Create EIP and bind it to bastion ECS instance |
| 10 | +1. Create NAT Gateway and add it to route table of VRouter |
| 11 | +1. Create a RDS instance in Vswitch and create database, db user |
| 12 | +1. Set ECS private ip address to RDS white list |
| 13 | + |
| 14 | +## How to use |
| 15 | +You can build wordpress by following process. But if you want to operate wordpress in production environment, you need to configure more. |
15 | 16 |
|
16 |
| -## 利用方法 |
17 |
| -基本的に下記の方法で実行可能です。 |
18 | 17 | ```
|
19 |
| -// 事前準備 |
20 |
| -$ cd wordpress_advanced_sample // 実行したいサンプルへ移動 |
21 | 18 | $ cp terraform.tfvars.sample terraform.tfvars
|
22 | 19 | $ vim terraform.tfvars
|
23 |
| - -> API KEYや公開鍵など必要情報更新 |
24 |
| -
|
25 |
| -// Dry-Run |
26 |
| -$ terraform plan -var-file="terraform.tfvars" |
| 20 | + => Edit variables with your favorite editor. |
27 | 21 |
|
28 |
| -// クラウドへ反映 |
29 |
| -$ terraform apply -var-file="terraform.tfvars" |
30 |
| -(略) |
31 |
| -Apply complete! Resources: x added, 0 changed, 0 destroyed. |
| 22 | +// Deploy to Alibaba Cloud |
| 23 | +$ terraform apply |
| 24 | +... |
| 25 | +Apply complete! Resources: 26 added, 0 changed, 0 destroyed. |
32 | 26 |
|
33 |
| -// 出力にRDSへの接続アドレスや踏み台のEIPのアドレスなどが表示されます |
34 | 27 | Outputs:
|
35 |
| -ecs_private_ip = 192.168.1.xx,192.168.1.xx |
36 |
| -fumidai_eip = xx.xx.xx.xx |
37 |
| -slb_ip = yy.yy.yy.yy |
38 |
| -rds_connection_string = xxxxxxxxx.rds.aliyuncs.com |
39 | 28 |
|
40 |
| -// 踏み台ECSへ接続 |
41 |
| -$ ssh ecs-user@xx.xx.xx.xx |
| 29 | +bastion_eip = <bastion_ip> |
| 30 | +ecs_private_ip = <wordpress_private_ip_1>,<wordpress_private_ip_2> |
| 31 | +rds_connection_string = <rds_connection_address> |
| 32 | +slb_ip = <slb_ip> |
| 33 | +``` |
42 | 34 |
|
43 |
| -// WordPress ECSへ接続 |
44 |
| -$ ssh root@192.168.1.xx |
| 35 | +``` |
| 36 | +// Connect to bastion ECS instance |
| 37 | +$ ssh ecs-user@<bastion_ip> |
45 | 38 |
|
46 |
| -// WordPress ECSの設定 |
47 |
| -$ wget https://raw.githubusercontent.com/mosuke5/terraform_for_alibabacloud_examples/master/wordpress_advanced_sample/provisioning_wordpress.sh |
48 |
| -$ sh provisioning_wordpress.sh |
49 |
| -/* このスクリプトで下記を行います |
50 |
| - - ecs-userの作成(パスワードはデフォルトではTest1234) |
51 |
| - - php, apacheのインストール |
52 |
| - - wordpressの配置 |
53 |
| - - sshの設定(rootログイン禁止) |
54 |
| -*/ |
| 39 | +// Then connect to wordpress ECS instance |
| 40 | +// You need to do this process two times, because you have two wordpress servers. |
| 41 | +$ ssh ecs-user@<wordpress_private_ip_1/2> |
| 42 | + -> Default ecs-user password is "Test1234" |
55 | 43 |
|
56 |
| -// WordPressの設定 |
| 44 | +// Configure wordpress |
57 | 45 | $ cd /var/www/html/wordpress
|
58 | 46 | $ sudo cp wp-config-sample.php wp-config.php
|
59 | 47 | $ sudo vim wp-config.php
|
60 |
| -/** WordPress のためのデータベース名 */ |
61 | 48 | define('DB_NAME', 'database_name_here');
|
62 |
| -
|
63 |
| -/** MySQL データベースのユーザー名 */ |
64 | 49 | define('DB_USER', 'username_here');
|
65 |
| -
|
66 |
| -/** MySQL データベースのパスワード */ |
67 | 50 | define('DB_PASSWORD', 'password_here');
|
68 |
| -
|
69 |
| -/** MySQL のホスト名 */ |
70 | 51 | define('DB_HOST', 'localhost');
|
| 52 | +``` |
71 | 53 |
|
| 54 | +After deploy and configuration to `wp-config.php`, let's access to your slb ip address. |
| 55 | +You will find wordpress installation screen. |
72 | 56 |
|
73 |
| -define('AUTH_KEY', 'put your unique phrase here'); |
74 |
| -define('SECURE_AUTH_KEY', 'put your unique phrase here'); |
75 |
| -define('LOGGED_IN_KEY', 'put your unique phrase here'); |
76 |
| -define('NONCE_KEY', 'put your unique phrase here'); |
77 |
| -define('AUTH_SALT', 'put your unique phrase here'); |
78 |
| -define('SECURE_AUTH_SALT', 'put your unique phrase here'); |
79 |
| -define('LOGGED_IN_SALT', 'put your unique phrase here'); |
80 |
| -define('NONCE_SALT', 'put your unique phrase here'); |
81 |
| -``` |
| 57 | +`http://<your slb ip address>/wordpress` |
| 58 | + |
| 59 | +## Provisioning to ECS for wordpress |
| 60 | +Wordpress ECS will be provisioned to following settings by Ansible. |
| 61 | + |
| 62 | +- Install Apache |
| 63 | +- Install PHP |
| 64 | +- Deploy WordPress source code |
| 65 | +- Create `ecs-user` |
| 66 | + - Add `ecs-user` to sudoers |
| 67 | + - Add your public key to `/home/ecs-user/.ssh/authorized_keys` |
| 68 | +- Disable root account login |
| 69 | + |
| 70 | +## Provisioning to ECS for bastion |
| 71 | +Bastion ECS will be provisioned to following settings by Ansible. |
82 | 72 |
|
83 |
| -## 利用開始 |
84 |
| -設定が完了したらブラウザから接続してみよう。 |
85 |
| -`http://<your slb address>/wordpress` |
| 73 | +- Create `ecs-user` |
| 74 | + - Add `ecs-user` to sudoers |
| 75 | + - Add your public key to `/home/ecs-user/.ssh/authorized_keys` |
| 76 | +- Disable password authentication and root account login |
0 commit comments