Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress with CloudFront + AMAZON RDS + S3

WordPress with CloudFront + AMAZON RDS + S3

#Creating JIN-KEI Simple Stack
- List of commands on this hands-on
https://github.com/amimoto-ami/hans-on-materials/blob/master/howto/simple-stack_en.md

More Decks by Amimoto - Flexible Cloud WordPress Hosting

Other Decks in How-to & DIY

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. AMAZON CloudFront •Global content delivery network (CDN) service •High data

    transfer speeds and reduce server load •Supports failover if a failure
  6. 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$-*
  7. • 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
  8. *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
  9. 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 •
  10. 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.
  11. Needs to edit (Line: 11–18) if ( !$db_data ) {

    $db_data = array( 'database' => '{Database Name}', 'username' => '{Master Username}', 'password' => '{Master Password}', 'host' => '{RDS_ENDPOINT}', ); }
  12. Disable MySQL autostart • Before { "mod_php7" : { "enabled":

    true }, "run_list" : [ "recipe[amimoto]" ] } • After { "mod_php7" : { "enabled": true }, "mysql": { "enabled": false }, "run_list" : [ "recipe[amimoto]" ] }
  13. Error Establishing a Database Connection • local-config.php still refers to

    previous DB in EC2 (AMIMOTO) • Make sure configuration of local-config.php
  14. 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
  15. $$MPVE'SPOU$MFBS$BDIF • CloudFront͸Ωϟογϡ࡟আ࣌ʹ՝ ۚ͞ΕΔͷͰཁ஫ҙ • Flush CloudFront Cache on WordPress

    • Flush automatically when article published/updated or manually • Pay as each request for invalidation
  16. Configure the plugin $ cd /var/www/vhosts/{INSTANCE_ID} $ wp plugin activate

    c3-cloudfront-clear-cache $ wp c3 update distribution_id <DISTRIBUTION_ID> $ wp c3 update access_key <AWS_ACCESS_KEY> $ wp c3 update secret_key <AWS_SECRET_KEY>