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

[日本語] How to use Amazon RDS & S3 with AMIMOTO A...

[日本語] How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

[日本語] How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

More Decks by Amimoto - Flexible Cloud WordPress Hosting

Other Decks in How-to & DIY

Transcript

  1. EC2 Λ RDS ΁઀ଓ͠·͢ 1. SSH Λ࢖͍Πϯελϯε΁ϩάΠϯ͠·͢
 
 $ ssh

    -i /Users/macpil/Desktop/example.pem ec2-user@instance_ip or domain
 2. ࣍ͷίϚϯυΛ࣮ߦ͍ͯͩ͘͠͞
 
 $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p 

  2. σʔλͷҠߦ wp-cli ͰσʔλϕʔεͷσʔλΛΤΫεϙʔτ:
 
 $ wp --path=/path/to/wordpress db export
 


    
 /path/to/wordpress ͸ WordPress ͷΠϯετʔϧσΟϨΫτϦͰ͢ɻ
 AMIMOTO AMIͷσϑΥϧτ͸ /var/www/vhosts/{instance_id} Ͱ͢ɻ

  3. Data migration RDS ΁σʔλΛΠϯϙʔτ: 
 
 $ mysql -h {endpoint}

    -P 3306 -u {mymasteruser} -p {databasename} < dump.sql
 
 {endpoint} ͸ AWS Ϛωʔδϝϯτίϯιʔϧʹදࣔ͞Ε͍ͯ·͢ɻ
 {mymasteruser} ͱ {databasename} ͸ RDS ࡞੒࣌ʹܾΊͨ΋ͷΛೖྗ͍ͯͩ͘͠͞ɻ
  4. wp-config.php ͷมߋ // ** MySQL settings - You can get

    this info from your web host ** // $db_data = false; if ( file_exists('/opt/aws/cloud_formation.json') ) { $db_data = json_decode(file_get_contents('/opt/aws/ cloud_formation.json'), true); if ( isset($db_data['rds']) ) { $db_data = $db_data['rds']; $db_data['host'] = $db_data['endpoint'] . ':' . $db_data['port']; } } if ( !$db_data ) { $db_data = array( 'database' => 'RDS_DATABASE_NAME_HERE', 'username' => 'RDS_USER_NAME_HERE', 'password' => 'RDS_PASSWORD_HERE', 'host' => 'RDS_ENDPOINT_HERE', ); }
  5. wp-config.php ͷมߋ RDS_DATABASE_NAME_HERE: DB ͷৄࡉઃఆͰࢦఆͨ͠σʔλϕʔε໊ RDS_USER_NAME_HERE: DB ͷৄࡉઃఆͰࢦఆͯͨ͠ϚελʔϢʔβ໊ RDS_PASSWORD_HERE: DB

    ͷৄࡉઃఆͰࢦఆͯͨ͠Ϛελʔύεϫʔυ RDS_ENDPOINT_HERE: RDS ͷΤϯυϙΠϯτ ͜ΕΒͷઃఆΛ wp-config.php ΁ઃఆޙ WordPress ͕ಈ࡞͢Δ͔֬ೝ͍ͯͩ͘͠͞ɻ
  6. AMIMOTO AMI ͷ MySQL Λఀࢭ͢Δ MySQL Λ RDS ΁Ҡಈͤ͞Δͱ AMIMOTO

    AMI ಺ͷ MySQL ϓϩηε͕ෆཁʹͳΓ·͢ɻ ઃఆϑΝΠϧΛฤूͯ͠ MySQL ϓϩηεΛऴ͍ྃͤͯͩ͘͞͞ɻ AMIMOTO AMI Ͱ͸ϛυϧ΢ΣΞͷઃఆ͸ /opt/local/amimoto.json ʹ͋Δ 
 chef-solo Λ࢖͍ͬͯ·͢ɻ
  7. Stoping MySQL in the AMIMOTO AMI MySQL Λ RDS ΁Ҡಈͤ͞Δͱ

    AMIMOTO AMI ಺ͷ MySQL ϓϩηε͕ෆཁʹͳΓ·͢ɻ ઃఆϑΝΠϧΛฤूͯ͠ MySQL ϓϩηεΛऴ͍ྃͤͯͩ͘͞͞ɻ AMIMOTO AMI Ͱ͸ϛυϧ΢ΣΞͷઃఆ͸ /opt/local/amimoto.json ʹ͋Δ 
 chef-solo Λ࢖͍ͬͯ·͢ɻ 
 MySQL Λఀࢭͤ͞Δʹ͸ϑΝΠϧΛ࣍ͷΑ͏ʹॻ͖׵͍͑ͯͩ͘͞:
 {
 "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "php" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "mysql" : { "enabled" : false },
 "phpfpm" : { "enabled" : true },
 "run_list" : [ "recipe[amimoto]" ]
 }
  8. AMIMOTO AMI ͷ MySQL ΛࢭΊΔ AMIMOTO AMI HHVM ൛ͷ৔߹͸ҎԼͷΑ͏ʹมߋ͍ͯͩ͘͠͞: {

    "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "php" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "mysql" : { "enabled" : false }, "hhvm" : { "enabled" : true }, "run_list" : [ "recipe[amimoto]" ] }
  9. AMAZON S3 • ΦϯϥΠϯόοΫΞοϓ͓Αͼ
 σʔλͷΞʔΧΠϒʹಛԽͨ͠ઃܭ • ੩తαΠτͷϗεςΟϯά΋Մೳ • 1ϑΝΠϧ͋ͨΓ 5GB

    ·ͰΞοϓϩʔυɼ
 ετϨʔδɼμ΢ϯϩʔυ͕Մೳ • ετϨʔδ͢ΔϑΝΠϧ਺ʹ্ݶͳ͠ • ෳ਺ͷσʔληϯλʹ৑௕Խ͞ΕετΞ