Tutorial: Deploying WordPress on AWS Elastic Beanstalk and Amazon RDS – Part 3/3

We started this tutorial by setting up the local git environment and configuring the AWS Elastic Beanstalk environment in part 1 and then created the MySQL Database in Amazon RDS in part 2. In the final part of this tutorial, we will export the database to Amazon RDS and deploy WordPress to AWS Beanstalk.

Step 4 – Exporting the database and deploying WordPress

Now that we have the environment configured in AWS Beanstalk and the MySQL database created in Amazon RDS, it is time for us to move WordPress to the Cloud.

First, we will export and import the MySQL Database. I am using the MySQL Workbench for this. But you can use either command line or PHPMyAdmin to export and import the database.

MySQL Workbench

MySQL Workbench

With the database exported to RDS, we are all set to move WordPress to AWS Beanstalk. But one final step is to change the wp-config.php to point WordPress to the RDS DB Instance. We will replace localhost with the RDS endpoint in the wp-config.php.

WordPress Configuration

Navigate to the WordPress folder and run the following commands
[crayon lang="shell"]
Git add .
Git commit – m “final check-in”
[/crayon]

The above command should result in the following indicating that the wp-config.php change is now committed.
1 file changed, 1 insertion(+), 1 deletion(-)

We are almost there! Time to run the last few commands to finish the deployment. Run the following commands to complete the deployment. Carefully enter the details that match with the AWS Elastic Beanstalk configuration that we created earlier.

[crayon lang="shell"]
git aws.config
[/crayon]

Deploy WordPress

Finally, take a deep breath and run the following command

[crayon lang="shell"]
git aws.push
[/crayon]

This will take a while as it uploads all the files to the AWS Beanstalk environment. After the upload is complete, make sure that the environment is healthy and green.

AWS Elastic Beanstalk

Clicking on the URL should open the WordPress blog running within AWS Elastic Beanstalk.

WordPress

Congratulations! You have successfully deployed WordPress on AWS Elastic Beanstalk!

Notice that the URL for the WordPress blog is now available at .elasticbeanstalk.com

WordPress

PS – If you have issues with rendering the blog correctly in the browser, log into the WordPress dashboard or change the settings in wp_options table to update the site settings to reflect the current URL.

- Janakiram MSV, Chief Editor, CloudStory.in



Comments

  • Hal Lesesne

    What happens when elastic beanstalk scales? If the admin has changed any content (specifically images), then when additional instances are created, the new instances won’t have those images. Any suggestions?

    • gilligoon

      Try this: install the plugin W3 Total Cache. Create a Cloudfront CDN on AWS S3. Configure W3TC to use the CDN for theme files and media upload files. This should move the files external from the instance, and W3TC will change the URLs to the CDN URLs. I plan to try this later, but in theory, and in my experience, it should work.

  • Justin

    Um… this completely ignores the issue of file uploads, which will totally break if you follow these instructions. The default is to save to the local fiilesystem, and the files will dnot be on any of the other instances.

    • http://danetidwell.com Dane Tidwell

      There is a wordpress plugin called Amazon S3 & Cloudfront which distributes files uploaded to the Media Manager to S3

  • http://www.bhagwad.com/blog/ Bhagwad Jal Park

    Thank you :)