Go Back   Technibble Forums > Operating Systems > Linux

  Technibble Sponsor

Thread Tools Display Modes
Old 03-19-2012, 02:24 AM
tankman1989's Avatar
tankman1989 tankman1989 is offline
Join Date: Apr 2009
Posts: 2,153
tankman1989 is on a distinguished road
Question Setting up Virtual Hosts in Apache2 - What a headache!

I'm having a hard time wrapping my head around this. I did this once before but now I' stuck. I found 3 decent sites explaining how to do this:


The problem is that there are tiny differences between them and I can't reconcile these differences. Does anyone here know how to do this and can give me pointer?

This is the line that is snaggin me on the file: /etc/apache2/sites-available/new_virtual_host_site_name
Add ServerName our-test-site.local just above the DocumentRoot directive (in front of line 4).

Edit DocumentRoot /var/www path on line 4 and set it to /path-to-the-test-site-WITHOUT-trailing-slash.
It should look something like this:
DocumentRoot /path-to-the-test-site-WITHOUT-trailing-slash
Ok so here is what I want to do. I am naming my site "ICS". I created the folder in /var/www/ics/ as I think this is where the data is going to be stored. This means that the file I'm editing is:
When I need to add the line to the above file do what do I use as the TLD (.local, .com, .net, etc?) This is what is different in each how-to's that is very comfusing. Most have .com but would that interfere with the real site on the internet that has the same domain name? How does it know to stay local?
ServerName ICS
Reply With Quote
Old 03-19-2012, 10:59 AM
coreyspeed coreyspeed is offline
Join Date: Mar 2010
Location: Hertfordshire, UK
Posts: 243
coreyspeed is an unknown quantity at this point

The sites-avaliable directoy is where you place the file with the virtual hosts config in. apache loads all the site from that directory.

to create a local domain use .local and either add the ip and domain to your hosts file or to your router (not sure on which part think its DNS). if you post what you have currently we can look through the settings.
Reply With Quote
Old 03-20-2012, 02:56 AM
mouse mouse is offline
Join Date: Oct 2010
Location: San Diego
Posts: 18
mouse is an unknown quantity at this point

You need to add the configuration file in the sites-available directory, then create a sym link to the sites-enabled directory, as this is where apache looks for sites that are enabled. If you are just messing with it locally you can use any extension just point it locally in the host file or the DNS if you use one. Look at the Apache documentation for examples of what the configuration file should look like at its most basic to work http://httpd.apache.org/docs/2.0/vhosts/examples.html
Reply With Quote
Old 12-04-2012, 06:28 PM
BM-Networking's Avatar
BM-Networking BM-Networking is offline
Join Date: May 2011
Location: Fresno, Ca
Posts: 92
BM-Networking is an unknown quantity at this point
Send a message via Skype™ to BM-Networking

I know I'm way late on this one, but through I'd post an answer anyways for others...

You can have your site in any folder, not just the /var/www/ics directory, you just need to change the location in the conf file. I usually place my sites in /home/www/ics.

The .net .local .com, etc... will be added to the config file under ServerName.

Then ensure the folder has the proper permission by running the following:

chown -R www-data:www-data /var/www/ics
Once that is done, you can enable the site by running this command

a2ensite ICS
Then restart or reload Apache.

service apache2 restart or /etc/init.d/apache2 restart

Network Consulting & Computer Repair in Fresno, Ca
Reply With Quote
Old 12-04-2012, 08:07 PM
krtechsolutions's Avatar
krtechsolutions krtechsolutions is online now
Join Date: Oct 2010
Posts: 553
krtechsolutions is on a distinguished road

download and install webmin
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 07:50 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Technibble.com is based out of MELBOURNE, AUSTRALIA.