Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

ΞʔΩςΫνϟ

Slide 3

Slide 3 text

AMAZON CloudFront AMAZON RDS AMAZON S3 w ߴ͍଱ো֐ੑΛ࣋ͭ%# w $%/Ͱίϯςϯπͷ഑৴Λߴ଎Խ w ௿ίετϝσΟΞετϨʔδ ࣮ݱ͢Δ͜ͱ

Slide 4

Slide 4 text

AWSαʔϏεͷ্ཱͪ͛ ϓϥάΠϯͷઃఆ Workflow ४උ

Slide 5

Slide 5 text

ߏஙલͷ ४උ

Slide 6

Slide 6 text

http://bit.ly/1VAnJ8q ίϚϯυ·ͱΊ

Slide 7

Slide 7 text

AWS CLIΠϯετʔϧ CloudFrontରԠ Workflow AMIMOTO AMIͷ४උ ߏஙલͷ ४උ

Slide 8

Slide 8 text

AWS CLIΠϯετʔϧ CloudFrontରԠ Workflow AMIMOTO AMIͷ४උ ߏஙલͷ ४උ

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

AMIMOTOΛ্ཱͪ͛ͨΒ͜ͷը໘·ͰਐΜͰࢭΊ͍ͯͩ͘͞

Slide 11

Slide 11 text

AWS CLIΠϯετʔϧ CloudFrontରԠ Workflow AMIMOTO AMIͷ४උ ߏஙલͷ ४උ

Slide 12

Slide 12 text

AWS CLI w "84ͷ$-*πʔϧ w ίϚϯυϥΠϯ͔Βૢ࡞Մೳ w $MPVE'SPOUͷηοτΞοϓʹར༻ "84$-*

Slide 13

Slide 13 text

IAMϢʔβʔͷ࡞੒ ॳظઃఆ Workflow AWS-CLIͷΠϯετʔϧ

Slide 14

Slide 14 text

IAMϢʔβʔͷ࡞੒ ॳظઃఆ Workflow AWS-CLIͷΠϯετʔϧ

Slide 15

Slide 15 text

1. Mac ΍ PC ΁ AWS ίϚϯυϥΠϯΠϯλʔϑΣΠε (aws-cli) ΛΠϯετʔϧ
 
 aws-cli ͷΠϯετʔϧํ๏͸ೋ௨Γ:
 - AWS ϢʔβΨΠυϖʔδͷखॱͰߦ͏:
 http://docs.aws.amazon.com/cli/latest/userguide/installing.html
 
 - Mac ͷ৔߹͸ ύοέʔδϚωʔδϟͷ Homebrew Λ࢖ͬͯΠϯετʔϧΛ͢Δ:
 http://brew.sh/index.html
 "84$-*ͷΠϯετʔϧ

Slide 16

Slide 16 text

࣍ͷίϚϯυΛλʔϛφϧ΁ίϐʔ&ϖʔετ͍ͯͩ͘͠͞ɻ
 $ /usr/bin/ruby -e "$(curl -fsSL https:// raw.githubusercontent.com/Homebrew/install/ master/install)"
 $ brew install wget
 $ brew install awscli
 .BDͰΠϯετʔϧ

Slide 17

Slide 17 text

8JOEPXTͰΠϯετʔϧ 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

IAMϢʔβʔͷ࡞੒ ॳظઃఆ Workflow AWS-CLIͷΠϯετʔϧ

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Identity and Access Management ΁Ҡಈ͠·͢

Slide 21

Slide 21 text

ϢʔβΛ࡞੒͠·͢

Slide 22

Slide 22 text

Ϣʔβ໊Λೖྗͯ͠ΞΫηεΩʔΛੜ੒͠·͢ BNJNPUPDMJ BNJNPUPDMJ

Slide 23

Slide 23 text

ηΩϡϦςΟΫϨσϯγϟϧΛอଘ͠·͢

Slide 24

Slide 24 text

ϙϦγʔΛϢʔβ΁ద༻͠·͢

Slide 25

Slide 25 text

͜͜Ͱ͸ CloudFrontFullAccess Λબ୒͍ͯͩ͘͠͞

Slide 26

Slide 26 text

͞Βʹ AmazonS3FullAccess Λબ୒͍ͯͩ͘͠͞

Slide 27

Slide 27 text

ϙϦγʔͷద༻͞Εͨ IAM Ϣʔβͷঢ়ଶͰ͢

Slide 28

Slide 28 text

IAMϢʔβʔͷ࡞੒ ॳظઃఆ Workflow AWS-CLIͷΠϯετʔϧ

Slide 29

Slide 29 text

aws configure --profile amimoto-cli

Slide 30

Slide 30 text

ઃఆΠϝʔδ 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 ͱAWS Secret Access Key

Slide 32

Slide 32 text

ઃఆΠϝʔδ 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Πϯετʔϧ CloudFrontରԠ Workflow AMIMOTO AMIͷ४උ ߏஙલͷ ४උ

Slide 34

Slide 34 text

aws --profile amimoto-cli configure set preview.cloudfront true ઃఆίϚϯυ

Slide 35

Slide 35 text

aws --profile amimoto-cli cloudfront help ಈ࡞֬ೝ

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

AWSαʔϏεͷ ηοτΞοϓ

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 •AWSͷϗετ͢ΔCDNαʔϏε •αΠτͷߴ଎Խͱෛՙ࡟ݮΛ࣮ݱ •ো֐࣌ͷϑΣΠϧΦʔόʔʹ΋ରԠ

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)" "84$-*͔ΒηοτΞοϓ

Slide 42

Slide 42 text

http://bit.ly/1VAnJ8q ίϚϯυ·ͱΊ

Slide 43

Slide 43 text

WordPress ͸ϧʔτσΟϨΫτϦ΁Πϯετʔϧ͍ͯͩ͘͠͞ɻ
 
 {ORIGIN URL HERE} - ΦϦδϯαʔόͷυϝΠϯ໊Λೖྗ͍ͯͩ͘͠͞ɻ
 IP ΞυϨεͰ͸ͳ͍ͷͰ͝஫ҙ͍ͩ͘͞ɻ ϋϯζΦϯͰ͸{ORIGIN URL HERE}͸EC2ͷ ύϒϦοΫDNSΛࢦఆ͠·͢ ஫ҙ఺

Slide 44

Slide 44 text

&$ʹύϒϦοΫ%/4͕ͳ͍৔߹

Slide 45

Slide 45 text

FYQPSUPSJHJO@VSMbFD99999999BQ OPSUIFBTUDPNQVUFBNB[POBXTDPN` BXTŠQSPpMFBNJNPUPDMJDMPVEGSPOUDSFBUFEJTUSJCVUJPODMJ JOQVUKTPO DVSMMTIUUQTSBXHJUIVCVTFSDPOUFOUDPN BNJNPUPBNJDSFBUFDGEJTUTFUUJOHTNBTUFS TPVSDF@EJTU@TFUUJOHTIcTI ೖྗΠϝʔδ

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

ηοτΞοϓ׬ྃ·Ͱ ̎̌ʙ̏̌෼

Slide 48

Slide 48 text

Amazon S3 Amazon RDS Workflow CloudFront

Slide 49

Slide 49 text

AMAZON S3 •AWSͷετϨʔδαʔϏε •৑௕Խ͞Ε͍ͯͯো֐ʹڧ͍ •ϑΝΠϧ਺ɾ༰ྔʹ্ݶͳ͠

Slide 50

Slide 50 text

AWS ίϯιʔϧͰ S3 Λબ୒͍ͯͩ͘͠͞

Slide 51

Slide 51 text

όέοτΛ࡞੒͠·͢

Slide 52

Slide 52 text

όέοτ΁෼͔Γ΍໊͍͢લΛ෇͚͍ͯͩ͘͞

Slide 53

Slide 53 text

όέοτͷ֓ཁը໘

Slide 54

Slide 54 text

Endpoint Λ߇͍͑ͯͩ͘͞

Slide 55

Slide 55 text

Enable website hosting Λબ୒͍ͯͩ͘͠͞

Slide 56

Slide 56 text

Index Document ͸ index.html Λೖྗ͍ͯͩ͘͠͞

Slide 57

Slide 57 text

[Save] Λԡͯ͠ઃఆΛอଘ͍ͯͩ͘͠͞

Slide 58

Slide 58 text

Amazon S3 Amazon RDS Workflow CloudFront

Slide 59

Slide 59 text

AMAZON RDS •AWSͷϗετ͢ΔDBαʔϏε •εϖοΫมߋͳͲ͕̍ΫϦοΫͰ •ෳ੡ʢϨϓϦΧ࡞੒ʣ΋؆୯

Slide 60

Slide 60 text

AMAZON RDS MariaDB Amazon Aurora બ΂ΔDBΤϯδϯ MySQL

Slide 61

Slide 61 text

DB੾Γସ͑ Workflow ηοτΞοϓ

Slide 62

Slide 62 text

DB੾Γସ͑ Workflow ηοτΞοϓ

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

ೖྗ͢Δ஋ • DB Instance IdentifierɿDBΠϯελϯε໊ • Master UsernameɿDBͷϧʔτϢʔβʔ໊ • Master PasswordɿDBͷϧʔτϢʔβʔύεϫʔυ • Confirm Passwordɿύεϫʔυͷ֬ೝ ͋ͱͰ࢖͏ͷͰɺςΩετΤσΟλͳͲʹϝϞ

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

".*.050Ͱ࢖͏ σʔλϕʔε໊

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

ٳܜ

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

σʔλϕʔεͷ 63-

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

DB੾Γସ͑ Workflow ηοτΞοϓ

Slide 79

Slide 79 text

MPDBMDPOpHQIQΛฤू $ sudo su - # cd /var/www/vhosts/{INSTANCE_ID} # vim local-config.php

Slide 80

Slide 80 text

มߋ͢Δ৔ॴʢ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

CloudFrontͷDNSͰαΠτʹΞΫηε

Slide 82

Slide 82 text

ඞཁͳ৘ใΛೖྗͯ͠ΠϯετʔϧΛ࣮ࢪ

Slide 83

Slide 83 text

Πϯετʔϧ׬ྃͷը໘

Slide 84

Slide 84 text

AMIMOTO(EC2)ͷ MySQLΛఀࢭ͢Δ

Slide 85

Slide 85 text

# vim /opt/local/amimoto.json

Slide 86

Slide 86 text

MySQLͷࣗಈىಈΛఀࢭ • 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

ʮσʔλϕʔε઀ଓΤϥʔʯ • local-config.php͸·ͩAMIMOTOͷDBΛࢀর͍ͯ͠·͢ • local-config.phpͷ಺༰Λ΋͏Ұ౓ݟ௚͍ͯͩ͘͠͞

Slide 89

Slide 89 text

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

WordPress ͷμογϡϘʔυͰ Nephila clavata ϓϥάΠϯΛ༗ޮԽ

Slide 93

Slide 93 text

ϓϥάΠϯͷઃఆΛߦ͍·͢

Slide 94

Slide 94 text

ೖྗ͢Δ஋ • AWS Access Keyɿamimoto-s3ͷaccesskey • AWS Secret Keyɿamimoto-s3ͷsecret key • AWS RegionɿϦʔδϣϯʢ೚ҙʣ • S3 Bucketɿઌ΄Ͳ࡞੒ͨ͠S3όέοτͷ໊લ • S3 URLɿઌ΄Ͳ࡞੒ͨ͠S3όέοτͷURL • Storage ClassɿSTANDARD

Slide 95

Slide 95 text

Amazon S3 ্΁Ҡಈͨ͠ WordPress ϝσΟΞϥΠϒϥϦ

Slide 96

Slide 96 text

CF Preview Fix C3 CloudFront Cache Clear Plugins Nephila clavata

Slide 97

Slide 97 text

$$MPVE'SPOU$MFBS $BDIF • WordPress͔ΒCloudFrontͷΩϟο γϡ࡟আ • هࣄެ։ɾߋ৽࣌ͱखಈͰ࡟আ • CloudFront͸Ωϟογϡ࡟আ࣌ʹ՝ ۚ͞ΕΔͷͰཁ஫ҙ

Slide 98

Slide 98 text

ϓϥάΠϯΛηοτΞοϓ͢Δ $ 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

[CF Preview Fix] ϓϥάΠϯΛΠϯετʔϧͯ͠༗ޮԽ͠·͢

Slide 102

Slide 102 text

Ϧιʔεͷ ࡟আ

Slide 103

Slide 103 text

AMAZON CloudFront CloudFrontͷແޮԽ

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

AMAZON RDS Amazon RDSͷ࡟আ

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

AMAZON S3 Amazon S3ͷ࡟আ

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

4όέοτͷ࡟আ • ϝσΟΞϑΝΠϧશͯ࡟আ͞Ε·͢ • όέοτ໊ΛଞͷϢʔβʔ͕औಘ͢ ΔՄೳੑ΋͋Δ

Slide 112

Slide 112 text

IAM IAMͷ࡟আ

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

AMAZON CloudFront CloudFrontͷ࡟আ

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

EC2ͷ࡟আ΋ ͓๨Εͳ͘

Slide 119

Slide 119 text

http://ja.amimoto-ami.com/slack/ ࣭͝໰͸͓ؾܰʹ:

Slide 120

Slide 120 text

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