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

How to use Amazon RDS & S3 with AMIMOTO AMI WordPress

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. ADVANTAGES • Scale your CPU, IOPS, and storage space
 •

    Snapshot-based on demand 
 and automatic backups
 • Multi Availability Zones deployment
 • Secondery synchronous instance in 
 case the primary fails
  2. DISADVANTAGES • No shell access to the DB instance
 •

    Restricted user privileges
 • Disabled replication in MySQL
 • Weekly 4-hour maintenance window
 • RDS Instance cannot be stopped
  3. Connecting your EC2 to RDS 1. Log into the root

    of your server using SSH:
 
 $ ssh -i /Users/macpil/Desktop/example.pem ec2-user@instance_ip or domain
 2. Run the following command:
 
 $ mysql -h {endpoint} -P 3306 -u {mymasteruser} -p 

  4. {endpoint} can be found in the RDS information of AWS

    Management Console
 {mymasteruser} and password are specified when you want to create RDS
  5. Data migration Export data via wp-cli:
 
 $ wp --path=/path/to/wordpress

    db export
 
 
 /path/to/wordpress is the directory where WordPress is installed
 In AMIMOTO AMI it’s usually /var/www/vhosts/{instance_id} 

  6. Data migration Import data to RDS:
 
 $ mysql -h

    {endpoint} -P 3306 -u {mymasteruser} -p {databasename} < dump.sql
 
 {endpoint} can be found in the RDS information of AWS Management Console
 {mymasteruser} and {databasename} are specified when you want to create RDS
  7. Rewriting 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', ); }
  8. Rewriting wp-config.php RDS_DATABASE_NAME_HERE Database Name which was set in Configure

    Advanced Settings RDS_USER_NAME_HERE Master Username which was set in Specify DB Details RDS_PASSWORD_HERE Master Password which was set in Specify DB Details RDS_ENDPOINT_HERE RDS endpoint When you set as above in wp-config.php, let’s check if you can connect to WordPress.
  9. Stoping MySQL in the AMIMOTO AMI Since MySQL was moved

    to RDS, MySQL process in AMIMOTO AMI is no longer necessary. Rewrite the configuration file, in AMIMOTO AMI, the middleware settings use chef-solo, where they are described in /opt/local/amimoto.json
  10. Stoping MySQL in the AMIMOTO AMI Since MySQL was moved

    to RDS, MySQL process in AMIMOTO AMI is no longer necessary. Rewrite the configuration file, in AMIMOTO AMI, the middleware settings use chef-solo, where they are described in /opt/local/amimoto.json 
 To stop starting MySQL, please rewrite the file:
 
 {
 "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "php" : { "config" : { "user" : "nginx", "group" : "nginx" } },
 "mysql" : { "enabled" : false },
 "phpfpm" : { "enabled" : true },
 "run_list" : [ "recipe[amimoto]" ]
 }
  11. Stoping MySQL in the AMIMOTO AMI For AMIMOTO AMI HHVM

    version, rewrite as follows: { "nginx" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "php" : { "config" : { "user" : "nginx", "group" : "nginx" } }, "mysql" : { "enabled" : false }, "hhvm" : { "enabled" : true }, "run_list" : [ "recipe[amimoto]" ] }
  12. Stoping MySQL in the AMIMOTO AMI Finally run the following

    command:
 
 $ sudo /opt/local/proviosion 
 $ mysql stop service
  13. AMAZON S3 • Scalable, high-speed, low-cost • Designed for online

    back and archiving
 of data • Static website hosting • Uploading, storage and downloading 
 of practically any file or object up to 5 GB • No limit on the number of items that 
 a subscriber can store • Data is stored on redundant servers 
 in multiple data centers