HOME HOME

Amazon EC2 - Ubuntu Apache2 Virtual Hosts Setup procedures

Procedures tested on Amazon EC2/ubuntu/Apache2 Instance (Procedures should also work on Debain Distribution but we did not test it)
Note1: These steps assume FTP server is already installed on the EC2 Instance (good docs on Installing vsftpd on an Amazon EC2 Ubuntu instance can be found here)
Note2: all commands require sudo for ubuntu (unless you are logged in as root user which is unlikely since you are using Amazon EC2 Instance )

Step0: Change DNS Records to point to the new Amazon EC2 IP address
Step1: Open Command Line Terminal (PuTTY for example)
Step2: Add a user with full access permissions to the site

adduser New-User-Name
Enter Password, Full Name, Room Number, etc.
Answer y to is this info correct question
Step2.1:Verify the user created by goin to the new user name directory under /home
cd /home/New-User-Name

Step3: Change the new user directory access writes to all allow write permisions

chmod a-w /home/New-User-Name

Step4: Create directory structure of your choice- we will use apps directory under which we will add all our site contents

mkdir apps
chown New-User-Name apps (change the owner of the directory to the new user
chgrp New-User-Name apps (change the group to the new user)
Step4.1: create site structure of your choice
using FTP create you site directory structure for example
your-site.com/www or htpdocs or mamboy or blablabla
your-site.com/logs

Step5: Enable site through apache

cd /etc/apache2/sites-available
creat a file with the name your-site.com that looks like this:
<VirtualHost *>

ServerAdmin [email protected]
ServerName www.your-site.com
ServerAlias your-site.com
# Indexes + Directory Root.
DirectoryIndex index.html index.php
DocumentRoot /home/your-site/www/
# Logfiles
ErrorLog /home/your-site/logs/error.log
CustomLog /home/your-site/logs/access.log combined

</VirtualHost>

Step5.1: enable the site

a2ensite your-site.com

Step6: Reload Apache service

service apache2 reload
service apache2 status