Last updated on July 31st, 2016 at 11:13 am

Amazon web service are one of the most popular for web applications. In some of my last post i explain how to setup amazon instance. Now in this post i explain how to setup multiple domain or  sub domain in your EC2 instance.

Step 1. Configure your EC2 instance or if you not yet created then create one 🙂  .

Step 2. Once your instance created allot elastic IP to your instance. Follow link to learn how to implement.

Step 3. If you buy your domain out side AWS then you need to point your domain to your instance address. In my case i buy domain from godaddy and point it to my instance as shown in below image.

Point domain to ec2 instance, Host multiple website on your EC2 instance AWS

Step 4. Now once you point your domain toward your instance your site is ready. Upload your website to /var/www/html.

Host Multiple Sites on a Single Amazon EC2 Instance

Step 1. Login to your instance with putty.

Host multiple website on your EC2 instance AWS

Step 2. After successful login type following command to edit Apache config file


sudo su
nano /etc/httpd/conf/httpd.conf

Step 3. After this add Virtual host and add your domain or sub domain and its location where you kept your files as shown below.


NameVirtualHost *:80
<VirtualHost *:80>
ServerName trinitytuts.com
ServerAdmin [email protected]
#SetEnv VAR_IF_YOU_NEED_ONE VALUE
RewriteEngine on
DocumentRoot "/var/www/trinitytuts/"
LogLevel warn
ServerSignature Off
#And whatever you need take a look to apache documentation
</VirtualHost>
<VirtualHost *:80>
ServerName api.trinitytuts.com
ServerAdmin [email protected]
DocumentRoot "/var/www/api"
</VirtualHost>

view raw

httpd.conf

hosted with ❤ by GitHub

thank you 🙂 hope this will help some one.