How to Host your WordPress Website on Amazon EC2 and S3

Looking for a basic procedure to host your WordPress website on Amazon S3 and EC2? This is all you need to read.

image

Technology

image

August 2, 2022

image

Mah Noor

image

Hosting your website on the cloud can enjoy a reliable, fast, and protected website (against any type of data loss).

In this article, I will let you know the basic procedure to host your WordPress website on Amazon S3 and EC2.

 

Hosting on Amazon S3

Hosting your images on Amazon s3 is a great option because you can stop worrying about backing up your images as S3 keeps multiple copies of your files and access to the images is very fast. It also reduces the load on your server of images.

 

Hosting on Amazon EC2

Amazon EC2 helps you in making resizable memory and compute capacity online (on the cloud).  Hosting on AWS gives you an awesome plug-and-play option for your server's hard disks, capacity, and computing power.

 

Why Hosting on AWS EC2 and S3 is Beneficial?

  • You can enjoy a flexible pricing structure for each service you want.
  • The configuration dashboard is so easy to manage. So that you can set it up if you have little experience with Amazon S3 and EC2.
  • You get scalable hosting.
  • Now, you have a highly available website.
  • You will feel at ease in loading high-potential resources (content pulling) for your website.

 

Process to Host your WordPress Website

Step-1:

  • Sign up for the Amazon Account. You will get the Access Key and API Key for this.
  • Add it to your WordPress plugin to access it in the Amazon directory.

Step-2:

  • You will get the Amazon Web Services Management Console.

Step-3:

  • Select the services which you are looking forward to.

Step-4:

  • On the service tab (select EC2 and S3).

Step-5: Steps for S3 

  • Click on S3 first.
    • Create a bucket on S3- The S3 bucket is actually a container like the structure of your website, that’s the bucket for your S3 asset for your WordPress website.
    • Now, you have to set up your WordPress website to communicate with the S3.
    • From the “Static Website Hosting” option, enable website hosting on your index page (that would probably be the first landing page of your website).
    • Enable website hosting indexed documents and error files in case of any error.
    • Upload all the files that you want to be in your S3 bucket. Your bucket is accessible privately. You can check out your bucket URL from the sidebar of S3. dashboard.
    • If you have developed a bucket earlier then, select the required bucket and hit upload to push your relevant content in the S3 Bucket.
    • After File upload, it will be pulled from that directory from the Amazon S3 bucket, where it was once saved.
    • After your file upload, you can make these file public to make them accessible via its AWS S3 bucket URL (in my case it’s: www.yourwebsite.com.s3_website-EU-west-1.amazonaws.com. The images and content can now be accessed from your S3 bucket.
    • You can add the bucket privacy policy from the “Permission” link on the left panel of the S3 bucket.  Click on ‘Add Bucket Policy’ to add a code for it. Now you can access all the content of your website publically.

{

 “Version”: “2012-10-17”,

 “Statement”: [

{

“Sid”: “PublicReadGetObject”,

“Effect”: “Allow”,

“Principal”: {

“AWS”: “*”

},

“Action”: “s3:GetObject”,

“Resource”: “arn:aws:s3:::YOUR-BUCKET-NAME-HERE/*”

}

 ]

}

Check for the URL of your website. Here is your website from the Amazon S3 bucket.

Step-6: Steps for EC2 

Now, for launching your EC2 Instance, follow the procedure below:

  • Just log in to your AWS console.
  • Find the EC2 under compute list under Amazon Web Services dashboard.
  • To configure your virtual machine, create and launch an EC2 instance.
  • After creating, configure your instance by going through the configuration wizard.
  • In the configuration setup, choose AWS marketplace that has WordPress installed. If not, then go to the left navigation panel and select AWS marketplace.
  • In the provided list click on WordPress and install it. Ongoing through its steps, review it.
  • On going through the next step, proceed it with or without key (as you want it).
  • Your instance is launched now. You can activate any subdomain or domain in it.
  • The Public IP is associated with the website, which you will be using for your website.
  • Your website is now launched, and all the assets are loaded via AWS. To make it accessible, with your very own URL, edit your “.htaccess” file.  
  • Run your EC2 instance, load your files and access it through its server now.

Step-7: Steps to Do on WordPress Dashboard End

Once you are done with creating the EC2 Instance for your website and making the S3 Bucket for your content, you now need to link it to the WordPress dashboard end.

For this, the necessary procedure is :

Install AWS Plugins

  • Go to the plugin area, and click on “Add Plugin”.
  • Search for the plugin named “ Amazon Web Services” which will house the Amazon Web Services (AWS) PHP libraries and manages access keys. Required by other AWS plugins.
  • Once installed, download another plugin for S3. It is advised to install the plugin named “Amazon S3 and Cloudflare”.
  • Activate both the plugins
  • Once activated, on the left panel find AWS, and click Access Key, it will ask you to add the Access API key and Secret Access Key for your AWS, just add it and Save Changes.
  • Now, Go for S3 and CloudFront,  and browse for the Existing Bucket, or Create a New one, depending upon the thing you want to get.
  • Set the path from where it will sync your images or content. Check for any other option, if it suits you.

Now, all the things are ready for work and your assets will launch from the S3 bucket when you add to your WordPress post or pages. It will automatically sync and load from AWS.

 

Conclusion

Vizteck Solutions can help you set up your existing hosting to Amazon AWS on scalable servers. Contact Us today for a quote.

Islamabad, Pakistan

Floor 2, Building 145, Civic Center Bahria Town Phase 4, Islamabad, Pakistan

USA

1 squire armor road, windham, NH,03076

Saudi Arabia

7654 Prince Nawaf Street, Al Khobar, 34426

Kingdom Of Bahrain

No 851, Bldg No 2420, Rd No 2831, Seef District, Block 428