Design Menace

Setting up Virtual Hosts on Ubuntu

Amazon Web Services

For the most part, I utilize AWS-EC2 to build one site per instance. Even subdomains are usually kept on separate instances. However, lately, I got a project where I would be setting up an instance and adding several different micro sites to one instance, and using a shared database. So, I figure I would need to setup some virtual hosts, which I had not done up to this point. What I found, was that this was very easy. Here’s how!

First thing to do is get into the directory that controls all this stuff.

[code]cd /etc/apache2/sites-available[/code]

Next enter this information into a file you create for your domain.  So first I would enter

[code]sudo pico[/code]

And they I would enter this information into the file and save it.

<VirtualHost *:80>

DocumentRoot {DIRECTORY}
ServerName {DOMAIN_NAME}

# Other directives here


Now you need to load it up into apache by running this.

[code]sudo a2ensite[/code]

And finally reload apache.

[code]sudo /etc/init.d/apache2 reload[/code]

Other links and information: