View Full Version : [ubuntu] Name-based Virtual hosting
programming.name
February 17th, 2010, 03:33 PM
Hi,
I am curruntly setting up a web hosting server with ubuntu 9.10 desktop edition and the situation is as follows:
1. Ubuntu lamp server installed; both http://127.0.0.1 and http://localhost work fine.
2. port-forward done and DNS resisterd.
3. got an purchased domain form a domain resistrar.
I am so confused right now becuase some info states that I need to copy and edit file(s) only in /etc/apache2/sites-available/ and others says httpd.conf or some also says apache2.conf as well as modyfing the hosts file.
Unfortunately '2-day-googling' on virtual hosting gives me nothing at all. All I want is to create subdomain with name-based virtual host.
Please HELP!
Thanks.
cdenley
February 17th, 2010, 05:27 PM
In ubuntu, any vhost related configuration belongs in /etc/apache2/sites-available. You should not use httpd.conf. When you create new vhost configurations, you enable them with "sudo a2ensite name_of_my_new_site".
http://ubuntuforums.org/showpost.php?p=8831431&postcount=2
programming.name
February 17th, 2010, 06:20 PM
Waht about hosts file? Do I need to edit it?
cdenley
February 17th, 2010, 06:27 PM
Waht about hosts file? Do I need to edit it?
Not really.
Mykle87
February 17th, 2010, 06:31 PM
I think this is what you want. (http://brucewampler.wordpress.com/2009/02/28/adding-virtual-hosts-to-ubuntu-apache/) I followed this guide and was able to host different web pages using different dynnds urls (such as mykle.dyndns.com and mykle2.dyndns.com) I had registered. I would assume this would work for your sub-domain. Good luck.
programming.name
February 17th, 2010, 06:45 PM
I Found the answer myself. We DO need to edit etc/hosts file as well. Please see below:
127.0.0.1 mydomain.com
127.0.0.1 sub1.mydomain.com
that solved the problem. Thanks
Iowan
February 17th, 2010, 07:57 PM
Here (http://httpd.apache.org/docs/2.0/vhosts/name-based.html) is a link I've had bookmarked for awhile - hope it helps.
cdenley
February 17th, 2010, 10:08 PM
I Found the answer myself. We DO need to edit etc/hosts file as well. Please see below:
127.0.0.1 mydomain.com
127.0.0.1 sub1.mydomain.com
that solved the problem. Thanks
That will cause your server to resolve your domains to 127.0.0.1, which may be required to view your site from the server itself in certain situations depending on your network/router/DNS. However, this is NOT required for a functional web server with multiple sites. Editing your hosts file will not affect how apache serves your pages, only how your web browser (which doesn't belong on a web server anyway) connects to apache.
pirateghost
February 17th, 2010, 10:34 PM
That will cause your server to resolve your domains to 127.0.0.1, which may be required to view your site from the server itself in certain situations depending on your network/router/DNS. However, this is NOT required for a functional web server with multiple sites. Editing your hosts file will not affect how apache serves your pages, only how your web browser (which doesn't belong on a web server anyway) connects to apache.
bingo. essentially all you did is tell your OS that when you call up mydomain.com or sub1.mydomain.com it points to localhost.
this does ZERO to create virtual name based servers
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.