4

I have been trying to integrate Amazon S3 & Amazon Cloudfront with my website (Hosted on Amazon EC2) developed using opencart from past few days. While searching, i found a lot of extensions from which not a single one fits the requirement. According to extensions all data be stored on local volume storage & you can create a sub-domain with directory root to /image/ directory & access the images form sub-domain. But here i do not see how the images and all get to Amazon S3. I might be missing something here. But below is what i want to implement.

What i want is to store all images & downloadable to Amazon S3 & retrieve the same from Amazon S3 using Amazon Cloudfront. When admin uploads an image then that gets stored in Amazon S3 instead of local volume storage.

I have gone through the /image/ models, library files which comes with opencart default installation. After seeing files, it looks impossible to implement what i want in current structure. The solution i see is rather i create my own library for this & update each & every file of opencart where images are being used or use any of the extensions present (using this will cause issues while using Amazon Elastic load balancing or Amazon Auto Scaling).

Any suggestions !!!

3 Answers3

0

Searching the market place I found this solution, Amazon CloudFront / S3 Integration

The extensions says:

speed up image loading on your website using Amazon CloudFront. This integration allows you to easily upload your OpenCart image cache onto S3 and serve it through CloudFront.

strongjz
  • 4,271
  • 1
  • 17
  • 27
  • Thanks for pointing this out. I have already checked this extension. The issue with this extension is that it stores only image cache on S3 bucket, all images remains on volume storage itself, which will cause problems while implementing Amazon ELB or Amazon Auto Scaling. – Anubhav Gupta Dec 31 '18 at 06:24
  • Ok, I see now. You want the webserver to serve images out of s3, not local volumes. And currently it is all implemented using opencart. – strongjz Dec 31 '18 at 12:19
  • Yes, this is what i want. – Anubhav Gupta Jan 01 '19 at 13:38
0

Finally i found the way for this. Basically we have two Questions in my above questions :- 1. Integrate Amazon S3 2. Integrate Amazon CloudFront

  1. Integrate Amazon S3 The best practice for this is to streamline all directories and files inside '{$ROOT}/image' completely with S3. Ultimately the goal is to make the application as much scalable as possible. This way when we put load balancer in front of our application then it won't create any issues as files no longer being saved on our local storage. To achieve this - one have to customize the application so that when ever admin add/update any images then they all get add/update to S3 instead of local storage. Also when images get pulled in website front then they all get pulled from S3 instead of local storage.

  2. Integrate Amazon CloudFront This has two options:- 2a. With S3 implemented - Just need to provide the S3:Bucket:ARN in amazon cloudfront and change the images url throughtout the web application. 2b. Without S3 (Local Storage used) - Instead of S3:Bucket:ARN we need to give image directory url of our application to amazon cloudfront for example:- www.example.com/image/ that's it. Now change the urls of images through out the web application and images will be pulled out from amazon cloudfront url.

0

The easiest way I found is to host in AWS Lightsail plan. Although the AWS Lightsail plan does not support Opencart by default we can use the LAMP stack and add the opencart code in it.

Host LAMP stack in AWS Lightsail, Opencart hosting in AWS

In this post we describe

  • How to set up an instance in Lightsail
  • How to select the free tier plan
  • Update system and PHP version in AWS Lightsail
  • Opencart installation steps in the AWS Lightsail LAMP stack
  • Create Static IP
  • Create DNS Zone
  • Add Name servers to your domain registrar
  • Create a database, database user and grant access
  • Install free Let’s Encrypt Certificate
  • Configure HTTP to HTTPS redirection for Opencart
  • Activate the SEO URL
  • How to setup FileZilla SFTP in AWS Lightsail to transfer files?
  • PHPMyAdmin access
  • How to upgrade to a higher Lightsail package?
  • How to set up the CDN?

Let us know if any questions or concerns.

Rupak Nepali
  • 719
  • 1
  • 6
  • 13