WordPress & Cloud: integration with AWS

Preview:

DESCRIPTION

How-to, tutorial and tips.

Citation preview

1 di 47

Cascina Roccafranca – Torino – 16 giugno 2012Gabriele Mittica – gabrielemittica.com – gabriele.mittica@corley.it - @gabrielemittica

WORDPRESS & AMAZON WEB SERVICES

2 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

CHAPTER 1.

INTRODUCING THE CLOUD

3 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

What is CLOUD COMPUTING?

Cloud computing refers to the delivery of computing and storage capacity as a service to a heterogeneous community of end-recipients.

Cloud computing entrusts services with a user's data, software and computation over a network.

It has considerable overlap with software as a service (SaaS).

4 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

FAQ about the cloud…Is the cloud just a fad?No.It’s a rational evolution of IT architecture towards a more efficient way of managing resources and designing Web applications efficiently.

Is the cloud cheap?No.The cloud allows you to pay the right for each service involved.

Is the cloud just a scalable vps?No.The cloud is a set of services designed to meet specific computing needs.

1.

2.

3.

5 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

Advantages

- access to unlimited resources

- scalable architecture

- no hardware dependency

- pay as you go

- geographical redundancy

- high availability

- increased competition for start-up

6 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

AWS - Amazon Web Services

Services

Scalable virtual machines

Storage services

Content delivery network

Autoscaling & loadbalancing

Realational & No-SQL DB

Private Cloud & Policies

… much more

Pricing

On-demand & reserved servers

Storage starting from 0.093$ / GB

Bill by credit card

Consolidated billing

Free tier

No setup fee

Dev & Social

SDK & xml webservices

Community forum

Premium support

Events & webinar

Start-up challenge

10 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

AWS - Links- Home page: http://aws.amazon.com/- About AWS: https://aws.amazon.com/what-is-aws/- All products: http://aws.amazon.com/products/- Dev area: http://aws.amazon.com/resources/- Documentation: http://aws.amazon.com/documentation/- SDK: http://aws.amazon.com/code/- Community: https://forums.aws.amazon.com/index.jspa- AWS Blog: http://aws.typepad.com/- Events: https://aws.amazon.com/about-aws/events/- Services Health Dashboard: http://status.aws.amazon.com/- Pricing Calculator: http://calculator.s3.amazonaws.com/calc5.html

11 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

CHAPTER 2.

WP + S3 + CLOUDFRONT

12 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront

Uploads your wordpress attachements to S3 with an option CloudFront distribution.

This WordPress plugin allows you to use Amazon's Simple Storage Service to host your media for your WordPress powered blog with an optional CloudFront distribution.

Plugin homepage: http://wordpress.org/extend/plugins/tantan-s3-cloudfront/

Services involved:Simple Storage Service (S3):S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It provides 99.999999999% durability.

CloudFront:CF can be used to deliver your entire website, including dynamic, static and streaming content using a global network of edge locations.Over 30 edge locations.

13 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront

Tipical use of WordPress: html and media files are provided by apache (http request):

14 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront

Thanks to S3 and CloudFront, you can easily send all your media files through the content Delivery Network

15 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configCreate a new user in aws console:

16 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configDownload Credentials:

17 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configThen set the policy:

18 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configGrant full access to S3 management:

19 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configCreate a new bucket in S3 console:

20 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configThen go in CloudFront console and create a new CF distribution:

21 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configSelect the bucket created as origin:

22 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configEnable the new cloudfront distribution:

23 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configDownload the wordpress Plugin (http://wordpress.org/extend/plugins/tantan-s3-cloudfront/) and follow these steps:

- Upload tantan-s3-cloudfront to the /wp-content/plugins/ directory- Activate the plugin through the 'Plugins' menu in WordPress- Configure the plugin in the 'Options' (or 'Settings') screen by following the

onscreen prompts.- Set an optional CloudFront distribution URL (must be paired with your S3

bucket on AWS)

24 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: configSet the plugin options:

25 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: usageNow each file uploaded is hosted by S3 and provided by CloudFront:

26 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + S3 + CloudFront: advantages

- Easy to use

- Cost affordable

- Very-low latency

- Reduced load on the server

- Increased page speed

- Useful in big files hosting, download repository, media files

- Useful in js/css/images distribution

27 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

CHAPTER 3.

WP + CLOUDFRONT

28 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront

CloudFront helps you to provide your content through a world wild content delivery network.

Following this how-to you can easily set CloudFront to provide all your data (html, css, js, images, videos and more).

You need:- An active AWS account- Dns management - Edit your wp-config.php file- No plugins required

Services involved:

CloudFront:CF can be used to deliver your entire website, including dynamic, static and streaming content using a global network of edge locations.Over 30 edge locations.

You need to edit the dns configuration of your website in order to use properly this tutorial.

29 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront

Tipical use of WordPress:

30 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront

Wordpress hosted by CloudFront:

31 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: config

Edit the dns configuration of your website:

www.example.com. CNAME your-cloudfront-distribution-url cdn.example.com. A your-server-ip

32 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: configThen go in CloudFront console and create a new CF distribution:

33 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: configSet your subdomain as origin:

34 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: configEnable the new CloudFront distribution:

35 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: config

Place in your wp-config.php file:

define('WP_ALLOW_MULTISITE', true);define('COOKIEPATH', '/');define('COOKIE_DOMAIN', '. example.com'); if(strpos($_SERVER['SCRIPT_NAME'], "/wp-login")===0 || strpos($_SERVER['SCRIPT_NAME'], "/wp-admin")===0) {

define('WP_HOME','http://cdn.example.com');define('WP_SITEURL','http://cdn.example.com');

}

36 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP + CloudFront: pros & cons

PROS:

- Fast implementation

- No-load on your server

- High-speed, low-latency

- Useful for product website or

website with heavy traffic

CONS:

- No POST data managed

- Comment system unavailable

(use DISQUS instead)

- Pay attention to cache timeout

37 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

CHAPTER 4.

SENDING EMAILS WITH SES

38 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

Sending emails with SES

WP-SES is a plugin that redirects all outgoing WordPress emails through Amazon Simple Email Service (SES) for maximum email delivrability.

You can download this plugin on official website http://wp-ses.com/

Requires: 3.0.0 or higherCompatible up to: 3.0.5

Services involved:

Simple Email Service (SES):SES is a highly scalable and cost-effective bulk and transactional email-sending service for businesses and developersOnly $0.10 per thousand.

39 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

Sending emails with SES: features

- Ability to adjust WordPress Default Sender Email and Name

- Validation of Amazon API Credentials

- Request confirmation for sender Emails

- Test message within Amazon Sandbox mode

- Full Test message within Amazon Production mode

- Full integration as seamless replacement for wp_mail internal function

- Dasboard panel with Quota and statistics

- Ability to customize return path for delivery failure notifications

40 di 47

41 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

Sending emails with SES: config

First, install like any other plugin:- Upload and activate the plugin- The setting are in settings / WP SESThen, proceed to the settings:- Fill the email address and name to use as the sender for all emails- Fill in Amazon API credentials- Save changes (Important !)- Ask to add the email as a confirmed sender- Click on the link you got by email from Amazon SES- Refresh the plugin, send a test email- If ok, ask Amazon to go out of sandbox into production mode- Once in production mode, you can use the top button to activate the plugin.

42 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

Sending emails with SES: configPlugin configuration:

43 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

CHAPTER 5.

WP HOSTING WITH AWS

44 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP hosting with AWS

Autoscaling+High Availability

Thanks to AWS you can setup Wordpress to scaling up and down and grant high-availability to your customers.

Some advantages:- Ability to Serve millions of pages/day- Ability to scale out/down dynamically- Should be Highly available- Automated Backup and Monitoring- Cost effective

-

This process involves a lot of services: EC2, Autoscaling, RDS, S3, ROUTE 53, CloudFront…

http://aws.amazon.com/products/

46 di 47Corley S.r.l.Piazza Statuto 10, Torino (10122)P.Iva 10669790015www.corley.it

WP hosting with AWS: links- How-to part one: http://

harish11g.blogspot.it/2012/01/scaling-wordpress-aws-amazon-ec2-high.html- How-to part two: http://

harish11g.blogspot.it/2012/02/wordpress-aws-ec2-architecture-part2.html- FAQ about WP on AWS: http://

harish11g.blogspot.in/2012/02/faq-scaling-wordpress-aws-ec2-million.html- Slides on SlideShare:

http://www.slideshare.net/harishganesan/scaling-wordpress-in-aws-amazon-ec2- AWS Architecture Center: http://aws.amazon.com/architecture/- AWS Web hosting architecture: http://

d36cz9buwru1tt.cloudfront.net/architecturecenter/AWS_ac_ra_web_01.pdf- WP on EC2 + RDS tutorial:

http://wp.tutsplus.com/tutorials/scaling-caching/deploy-your-wordpress-blog-to-the-cloud/

47 di 47

Cascina Roccafranca – Torino – 16 giugno 2012Gabriele Mittica – gabrielemittica.com – gabriele.mittica@corley.it - @gabrielemittica

Thank you for listening

Recommended