This is a discussion on domain hosting configuration within the Apache Web Server forums, part of the Web Server and Related Forums category; I am an apache newbie. I have various domain addresses forwarding to my web server, I would like to have ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am an apache newbie.
I have various domain addresses forwarding to my web server, I would like to have apache direct the requests to the appropriate site. For example, site.com -> goes to the site.com web folder site2.com -> goes to the site2.com folder site3.com -> goes to the site3.com folder Is this possible? How do I set it up so that I can have a single apache webserver responding / serving multiple sites? Matt |
|
|||
|
Milo Hoffman wrote:
> I am an apache newbie. > > I have various domain addresses forwarding to my web server, I would > like to have apache direct the requests to the appropriate site. > > For example, > > site.com -> goes to the site.com web folder > site2.com -> goes to the site2.com folder > site3.com -> goes to the site3.com folder > > Is this possible? How do I set it up so that I can have a single apache > webserver responding / serving multiple sites? > > Matt > VirtualHosts - try reading the apache documentation like the rest of us had to. http://httpd.apache.org/docs/ Very basically (man I am nice): <VirtualHost *:80> DocumentRoot "/path/to/site.com/folder/" ServerName www.site.com </VirtualHost> -- BC |
|
|||
|
BlueC wrote:
> Milo Hoffman wrote: >> I am an apache newbie. >> >> I have various domain addresses forwarding to my web server, I would >> like to have apache direct the requests to the appropriate site. >> Didn't see that "forwarding" bit - what do you mean by "forwarding"? Do you mean the DNS record is pointing the domain to your server IP address? If so that will work with VirtualHosts. If you mean something else, then it probably won't. -- BC |
|
|||
|
What I mean is I have multiple .com addresses. 3 to be specific. They
are all pointing to my server IP. I want apache to serve the correct site to each request when it hits my site. Right now any one of them will see the same default site. So will VirtualHosts accomplish this? BlueC wrote: > BlueC wrote: > > Milo Hoffman wrote: > >> I am an apache newbie. > >> > >> I have various domain addresses forwarding to my web server, I would > >> like to have apache direct the requests to the appropriate site. > >> > > Didn't see that "forwarding" bit - what do you mean by "forwarding"? > > Do you mean the DNS record is pointing the domain to your server IP > address? If so that will work with VirtualHosts. If you mean something > else, then it probably won't. > > -- > BC |
|
|||
|
Milo Hoffman wrote:
> What I mean is I have multiple .com addresses. 3 to be specific. They > are all pointing to my server IP. I want apache to serve the correct > site to each request when it hits my site. Right now any one of them > will see the same default site. > > So will VirtualHosts accomplish this? > Yes. VirtualHosts will accomplish that. You just need a different VirtualHost for each domain. I just got confused by the term "forwarding" because that is sometimes used to describe something else. Below is how to do it, but seriously, read the apache docs, they will help you a GREAT deal. <VirtualHost *:80> DocumentRoot "/path/to/site1.com/folder/" ServerName www.site1.com ServerAlias site1.com # Other stuff </VirtualHost> <VirtualHost *:80> DocumentRoot "/path/to/site2.com/folder/" ServerName www.site2.com </VirtualHost> .... etc ... -- BC |
|
|||
|
Thanks! I will definately read through the docs on this and other
topics. BlueC wrote: > Milo Hoffman wrote: > > What I mean is I have multiple .com addresses. 3 to be specific. They > > are all pointing to my server IP. I want apache to serve the correct > > site to each request when it hits my site. Right now any one of them > > will see the same default site. > > > > So will VirtualHosts accomplish this? > > > > Yes. VirtualHosts will accomplish that. You just need a different > VirtualHost for each domain. > > I just got confused by the term "forwarding" because that is sometimes > used to describe something else. > > Below is how to do it, but seriously, read the apache docs, they will > help you a GREAT deal. > > <VirtualHost *:80> > DocumentRoot "/path/to/site1.com/folder/" > ServerName www.site1.com > ServerAlias site1.com > # Other stuff > </VirtualHost> > > <VirtualHost *:80> > DocumentRoot "/path/to/site2.com/folder/" > ServerName www.site2.com > </VirtualHost> > > ... etc ... > > -- > BC |
|
|||
|
So I have successfully hosted two sites on the same box. I am quite
pleased. However, I have a strange problem. I have aliased the sites so either can be reached from www.site.com or site.com, however, the second site (site2.com in this example) cannot be reached without the www in front of it. I get a timeout error! It doesn't make sense to me as I have literally copy and pasted the vhost config from the first one I did (site1 in this example). Any idea what I have done wrong? NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "C:/www/site1" ServerName site1.com ServerAlias www.site1.com ErrorLog "C:/www/site1-error_log.txt" CustomLog "C:/www/site1-access_log.txt" common </VirtualHost> # # This is to permit URL access to scripts/files in www/site1 directory # <Directory "C:/www/site1"> allow from all </Directory> <VirtualHost *:80> DocumentRoot "C:/www/site2" ServerName site2.com ServerAlias www.site2.com ErrorLog "C:/www/site2-error_log.txt" CustomLog "C:/www/site2-access_log.txt" common </VirtualHost> # # This is to permit URL access to scripts/files in www/site2 directory # <Directory "C:/www/site2"> allow from all </Directory> BlueC wrote: > Milo Hoffman wrote: > > What I mean is I have multiple .com addresses. 3 to be specific. They > > are all pointing to my server IP. I want apache to serve the correct > > site to each request when it hits my site. Right now any one of them > > will see the same default site. > > > > So will VirtualHosts accomplish this? > > > > Yes. VirtualHosts will accomplish that. You just need a different > VirtualHost for each domain. > > I just got confused by the term "forwarding" because that is sometimes > used to describe something else. > > Below is how to do it, but seriously, read the apache docs, they will > help you a GREAT deal. > > <VirtualHost *:80> > DocumentRoot "/path/to/site1.com/folder/" > ServerName www.site1.com > ServerAlias site1.com > # Other stuff > </VirtualHost> > > <VirtualHost *:80> > DocumentRoot "/path/to/site2.com/folder/" > ServerName www.site2.com > </VirtualHost> > > ... etc ... > > -- > BC |
|
|||
|
Milo Hoffman wrote:
> So I have successfully hosted two sites on the same box. I am quite > pleased. However, I have a strange problem. > > I have aliased the sites so either can be reached from www.site.com or > site.com, however, the second site (site2.com in this example) cannot > be reached without the www in front of it. I get a timeout error! It > doesn't make sense to me as I have literally copy and pasted the vhost > config from the first one I did (site1 in this example). > > Any idea what I have done wrong? > Odd indeed. Restarted apache? Checked that your DNS entries are correct for the site2.com and www.site2.com? -- BC |