The main advantage of hosting your website on amazon EC2 is that you have full control over the server. You can do anything with the server unlike other hosting providers where the things you can do with the server are limited. You can have a high availability architecture for your application on aws. With the right combination of EC2 ,ELB and route53 you can have a highly scalable and available application on AWS.
You might like :Amazon Web Services – Web Hosting & Cloud Computing With AWS
You can host a php application on AWS using two methods,
1. Hosting it directly on an EC2 instance: In this scenario, you have to launch, install and configure the application environment.
2. Using elastic beanstalk: Elastic beanstalk is a an app deployment service, using which you can deploy a php application with few clicks. EC2 instances, load balancer, autoscaling etc,, everything will be setup automatically in the backend using elastic beanstalk. All you have to do is just upload your application using the management console. The instances created by elastic beanstalk is accessible by the user. Amazon wont charge you for elastic beanstalk service, but will charge only for the resources created in the backend.
Also read: How to host application on AWS elastic beanstalk
In this tutorial i will explain the first scenario where you have to setup the instance and webserver manually.
Tutorial for hosting a dynamic site using EC2
1. Launch an instance: View this tutorial to launch an instance How to launch an instance on Amazon EC2
2. Connect to your EC2 instance using putty: Follow this tutorial to How to connect an EC2 instance using putty
Update the server using the following command
sudo apt-get update
3. Install Lampserver : install web server using the following command
sudo apt-get install lamp-server^
The above command will install apache web server , php and Mysql. For a detailed tutorial for installing the lamp stack you can refer this tutorial How To Install Lamp Stack On Amazon EC2
4. Now copy and paste the public DNS of your instance in the address bar of the browser and click enter. If it shows a page showing the message “It Works
5. Uploading Web Pages to WWW Folder: After the web server has been installed you have to upload your web pages to the www folder of
You can upload the files to your instance using
By default www folder contains index.html. Remove that default index.html and start uploading your HTML, CSS and PHP files to the server inside www folder.
Hosting A Static Website Using S3: In S3 we can host only static websites. If you want your dynamic website run on
Hosting a static website in S3 is a simple process, just design your pages locally in a computer and just upload it to S3 buckets.
1. Login to Amazon S3 dashboard and create a bucket and give it your desired website name. eg: comtechies.com and also select the region you want to host your website.
2. Now select the bucket you created and click upload button at the left top corner. A window will pop up asking you to add files. Click add files and select the webpages of the website you designed and then click start upload.
3. Once the files are
eg: https://s3.amazonaws.com/comtechies.com/index.html. [amazon bucket address]
4. The amazon bucket address bit lengthy and if you would prefer to