This is the example of building wordpress with ECS and RDS. Architecture overview is here.
- Create VPC
- Create Vswitch
- Create Security Group and set some rules
- Create an ECS instance in Vswitch
- Create EIP and bind it to ECS instance
- Create a RDS instance in Vswitch and create database, db user
- Set ECS private ip address to RDS white list
You can build wordpress by following process. But if you want to operate wordpress in production, you need to configure more.
$ cp terraform.tfvars.sample terraform.tfvars
$ vim terraform.tfvars
=> Edit variables with your favorite editor.
// Deploy to Alibaba Cloud
$ terraform apply
...
Apply complete! Resources: 12 added, 0 changed, 0 destroyed.
Outputs:
rds_connection_string = xxxxxxxxx.rds.aliyuncs.com
wordpress_eip = xx.xx.xx.xx
// Connect to ECS instance with ssh
$ ssh [email protected]
// Configure wordpress
$ cd /var/www/html/wordpress
$ sudo cp wp-config-sample.php wp-config.php
$ sudo vim wp-config.php
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');
After deploy and configuration to wp-config.php
, let's access to your eip address.
You will find wordpress installation screen.
http://<your eip address>/wordpress
ECS will be provisioned for following settings by Ansible.
- Install Apache
- Install PHP
- Deploy WordPress source code
- Create
ecs-user
- Add
ecs-user
to sudoers - Add your public key to
/home/ecs-user/.ssh/authorized_keys
- Add
- Disable password authentication and root account login