Slide 1

Slide 1 text

WordPress with CloudFront + AMAZON RDS + S3 @Amimoto_Ami amimoto-ami.com

Slide 2

Slide 2 text

Architecture

Slide 3

Slide 3 text

AMAZON CloudFront AMAZON RDS AMAZON S3 w %#XJUIIJHIGBJMVSFUPMFSBODF w TQFFEVQDPOUFOUTEFMJWFSZXJUI$%/ w $PTUF⒎FDUJWFNFEJBTUPSBHFT (PBM

Slide 4

Slide 4 text

Starting up AWS services Plugins configurations Workflow Preparations

Slide 5

Slide 5 text

Preparations for construction

Slide 6

Slide 6 text

http://bit.ly/1Xio3cC -JTUPGDPNNBOET

Slide 7

Slide 7 text

AWS CLI installation CloudFront corresponding Workflow Start up AMIMOTO AMI preparations

Slide 8

Slide 8 text

AWS CLI installation CloudFront corresponding Workflow Start up AMIMOTO AMI preparations

Slide 9

Slide 9 text

https://aws.amazon.com/marketplace/pp/B01DAONMCK/

Slide 10

Slide 10 text

When you start up AMIMOTO, 
 step forward until this “Welcome” page.

Slide 11

Slide 11 text

AWS CLI installation CloudFront corresponding Workflow Start up AMIMOTO AMI preparations

Slide 12

Slide 12 text

AWS CLI w $PNNBOE-JOF*OUFSGBDFGPS"84 w :PVDBONBOJQVMBUFBMMUISPVHI DPNNBOEMJOF w 'PSDPOpHVSFUIF$MPVE'SPOU "84$-*

Slide 13

Slide 13 text

Create IAM user Initial setup Workflow AWS-CLI installation

Slide 14

Slide 14 text

Create IAM user Initial setup Workflow AWS-CLI installation

Slide 15

Slide 15 text

1. Install AWS Command Line Interface (aws-cli) to your Mac or PC
 
 Two ways to install aws-cli:
 - Install follow the AWS user guide page:
 http://docs.aws.amazon.com/cli/latest/userguide/installing.html
 
 - Install through package manager Homebrew, if you use Mac:
 http://brew.sh/index.html
 "84$-*JOTUBMMBUJPO

Slide 16

Slide 16 text

Copy below command and pate into your terminal.app then hit [return] key
 $ /usr/bin/ruby -e "$(curl -fsSL https:// raw.githubusercontent.com/Homebrew/install/ master/install)"
 $ brew install wget
 $ brew install awscli
 'PS.BDVTFST

Slide 17

Slide 17 text

'PS8JOEPXTVTFS w %PXOMPBEUIF"84$-*.4*JOTUBMMFSGPS8JOEPXT CJU  IUUQTTBNB[POBXTDPNBXTDMJ"84$-*NTJ w %PXOMPBEUIF"84$-*.4*JOTUBMMFSGPS8JOEPXT CJU  IUUQTTBNB[POBXTDPNBXTDMJ"84$-*NTJ

Slide 18

Slide 18 text

Create IAM user Initial setup Workflow AWS-CLI installation

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

move to Identity and Access Management

Slide 21

Slide 21 text

Create new user

Slide 22

Slide 22 text

Enter a user name and generate access key. BNJNPUPDMJ BNJNPUPDMJ

Slide 23

Slide 23 text

Save security credentials to your local (anywhere you want)

Slide 24

Slide 24 text

Attach policy to created user

Slide 25

Slide 25 text

Choose CloudFrontFullAccess and…

Slide 26

Slide 26 text

Choose AmazonS3FullAccess then click [Attach Policy]

Slide 27

Slide 27 text

Two policies are attached to the user

Slide 28

Slide 28 text

Create IAM user Initial setup Workflow AWS-CLI installation

Slide 29

Slide 29 text

aws configure --profile amimoto-cli

Slide 30

Slide 30 text

4BNQMFDPOpHVSBUJPO AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXX
 AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 Default region name [None]: ap-northeast-1
 Default output format [None]: JSON

Slide 31

Slide 31 text

AWS Access Key ID and AWS Secret Access Key

Slide 32

Slide 32 text

4BNQMFDPOpHVSBUJPO AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXX
 AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 Default region name [None]: ap-northeast-1
 Default output format [None]: JSON

Slide 33

Slide 33 text

AWS CLI installation CloudFront corresponding Workflow Start up AMIMOTO AMI preparations

Slide 34

Slide 34 text

aws --profile amimoto-cli configure set preview.cloudfront true $POpHVSBUJPODPNNBOE

Slide 35

Slide 35 text

aws --profile amimoto-cli cloudfront help $POpHVSBUJPODIFDL

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Setting up 
 AWS services

Slide 38

Slide 38 text

Amazon RDS Amazon S3 Workflow CloudFront

Slide 39

Slide 39 text

Amazon RDS Amazon S3 Workflow CloudFront

Slide 40

Slide 40 text

AMAZON CloudFront •Global content delivery network (CDN) service •High data transfer speeds and reduce server load •Supports failover if a failure

Slide 41

Slide 41 text

export origin_url='{ORIGIN URL}'; aws --profile amimoto-cli cloudfront create-distribution --cli-input-json "$(curl -l -s https:// raw.githubusercontent.com/amimoto- ami/create-cf-dist-settings/master/ source_dist_setting.sh | sh)" 4FUUJOH$MPVE'SPOUVQXJUI"84$-*

Slide 42

Slide 42 text

http://bit.ly/1VAnJ8q -JTUPGDPNNBOET

Slide 43

Slide 43 text

• Install WordPress into the server’s document root directory; • Replace {ORIGIN URL} to the server domain name (or Public DNS) of AMIMOTO; • Change amimoto-cli to your created profile, if necessary; • On this hands-on, set Public DNS of EC2 to {ORIGIN URL} /PUF

Slide 44

Slide 44 text

*GZPVDBOOPUpOE1VCMJD%/4PO&$ Check following documents: Updating DNS Support for Your VPC http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc- dns.html#vpc-dns-updating or AWSͰPublic DNS(ύϒϦοΫDNS)ׂ͕Γ౰ͯΒΕͳ͍࣌ͷղܾ๏ http://qiita.com/kasokai/items/4ea689ce9f206e78a523

Slide 45

Slide 45 text

FYQPSUPSJHJO@VSMbFD99999999BQ OPSUIFBTUDPNQVUFBNB[POBXTDPN` BXTŠQSPpMFBNJNPUPDMJDMPVEGSPOUDSFBUFEJTUSJCVUJPODMJ JOQVUKTPO DVSMMTIUUQTSBXHJUIVCVTFSDPOUFOUDPN BNJNPUPBNJDSFBUFDGEJTUTFUUJOHTNBTUFS TPVSDF@EJTU@TFUUJOHTIcTI  4BNQMFDPOpHVSBUJPO

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

20-30 minutes to complete for 
 CloudFront starts up

Slide 48

Slide 48 text

Amazon S3 Amazon RDS Workflow CloudFront

Slide 49

Slide 49 text

AMAZON S3 •AWS storage service •Data is stored on redundant servers 
 in multiple data centres •High fault tolerance •No limit on the number of items 
 can be stored •

Slide 50

Slide 50 text

Click S3 on AWS Console page.

Slide 51

Slide 51 text

Create a bucket

Slide 52

Slide 52 text

Name a bucket; unique and easy to specify

Slide 53

Slide 53 text

Bucket properties

Slide 54

Slide 54 text

Copy Endpoint and paste it to the text file.

Slide 55

Slide 55 text

Choose Enable website hosting

Slide 56

Slide 56 text

Input index.html into Index Document

Slide 57

Slide 57 text

Click [Save] to apply settings.

Slide 58

Slide 58 text

Amazon S3 Amazon RDS Workflow CloudFront

Slide 59

Slide 59 text

AMAZON RDS •Managed DB service •Single click to change specification •Easy to replication

Slide 60

Slide 60 text

AMAZON RDS MariaDB Amazon Aurora Various DB engine MySQL

Slide 61

Slide 61 text

Switching DB to RDS Workflow Set up

Slide 62

Slide 62 text

Switching DB to RDS Workflow Set up

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

Values to input • DB Instance IdentifierɿName of DB instance • Master UsernameɿRoot user of DB • Master PasswordɿPassword for root user of DB • Confirm PasswordɿConfirmation password for root user of DB Copy and paste them to notepad and save as text file.

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

)PTUOBNFPG EBUBCBTF

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Coffee break

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

%BUBCBTF63-

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

Switching DB to RDS Workflow Set up

Slide 79

Slide 79 text

&EJUMPDBMDPOpHQIQ $ sudo su - # cd /var/www/vhosts/{INSTANCE_ID} # vim local-config.php

Slide 80

Slide 80 text

Needs to edit (Line: 11–18) if ( !$db_data ) { $db_data = array( 'database' => '{Database Name}', 'username' => '{Master Username}', 'password' => '{Master Password}', 'host' => '{RDS_ENDPOINT}', ); }

Slide 81

Slide 81 text

Access to CloudFront’s DNS with your browser

Slide 82

Slide 82 text

Back to WordPress’ set up page. Fill in required field then install WordPress.

Slide 83

Slide 83 text

Installation has completed

Slide 84

Slide 84 text

Stop MySQL on AMIMOTO(EC2)

Slide 85

Slide 85 text

# vim /opt/local/amimoto.json

Slide 86

Slide 86 text

Disable MySQL autostart • Before { "mod_php7" : { "enabled": true }, "run_list" : [ "recipe[amimoto]" ] } • After { "mod_php7" : { "enabled": true }, "mysql": { "enabled": false }, "run_list" : [ "recipe[amimoto]" ] }

Slide 87

Slide 87 text

# /opt/local/provision

Slide 88

Slide 88 text

Error Establishing a Database Connection • local-config.php still refers to previous DB in EC2 (AMIMOTO) • Make sure configuration of local-config.php

Slide 89

Slide 89 text

Set up plugins for WordPress

Slide 90

Slide 90 text

C3 CloudFront Cache Clear CF Preview Fix Plugins Nephila clavata

Slide 91

Slide 91 text

CF Preview Fix C3 CloudFront Cache Clear Nephila clavata Plugins

Slide 92

Slide 92 text

Activate Nephila clavata plugin on WordPress Dashboard

Slide 93

Slide 93 text

Configure the plugin

Slide 94

Slide 94 text

Values to input • AWS Access Key: Access key for IAM user amimoto-s3 • AWS Secret Key: Access key for IAM user amimoto-s3 • AWS Region: Region (optional) • S3 Bucket: S3 bucket name • S3 URL: S3 bucket URL • Storage Class: Choose STANDARD

Slide 95

Slide 95 text

Media library copied onto Amazon S3

Slide 96

Slide 96 text

CF Preview Fix C3 CloudFront Cache Clear Plugins Nephila clavata

Slide 97

Slide 97 text

$$MPVE'SPOU$MFBS$BDIF • CloudFront͸Ωϟογϡ࡟আ࣌ʹ՝ ۚ͞ΕΔͷͰཁ஫ҙ • Flush CloudFront Cache on WordPress • Flush automatically when article published/updated or manually • Pay as each request for invalidation

Slide 98

Slide 98 text

Configure the plugin $ cd /var/www/vhosts/{INSTANCE_ID} $ wp plugin activate c3-cloudfront-clear-cache $ wp c3 update distribution_id $ wp c3 update access_key $ wp c3 update secret_key

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

CF Preview Fix C3 CloudFront Cache Clear Plugins Nephila clavata

Slide 101

Slide 101 text

Install and activate [CF Preview Fix] plugin

Slide 102

Slide 102 text

Removing resources

Slide 103

Slide 103 text

AMAZON CloudFront Disable CloudFront

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

AMAZON RDS Delete Amazon RDS

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

AMAZON S3 Delete Amazon S3

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

%FMFUF4CVDLFU • All media are removed permanently • Someone will create same S3 bucket name

Slide 112

Slide 112 text

IAM Delete the created 
 IAM user

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

AMAZON CloudFront Delete CloudFront

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

Never forget delete EC2

Slide 119

Slide 119 text

http://amimoto-ami.com/slack/ Feel free to contact us!

Slide 120

Slide 120 text

@Amimoto_Ami amimoto-ami.com THANK YOU! WordPress with CloudFront + AMAZON RDS + S3