PDA

View Full Version : Subdomains w/apache & DDNS



magnav0x
04-05-2003, 10:01 PM
Ok I know some around this board will be familiar with doing this, but this is my first attempt. I registered one of my older domains with a DDNS service so I may host it myself. I got that all set up find and I can access the hostname just fine. I'm currently trying to setup sub domains, which is giving me problems. I registered a subdomain with the DDNS serivice (A) and configured my apache httpd.conf file like so:

<VirtualHost stats.technosapiens.cc>
DocumentRoot c:/phpweb/users/stats
ServerName stats.technosapiens.cc
ErrorLog c:/phpweb/users/stats/logs/error.log
TransferLog c:/phpweb/users/stats/logs/transfer.log
</VirtualHost>

Of course this is on Windows (win2k) and my docroot is c:\phpweb. I put what I wanted to use for the "stats" subdomain in c:\phpweb\users\stats\ (my preference, doesn't matter though). When I goto stats.technosapiens.cc instead of seeing what's in the stats folder, I get the exact same output that www.technosapiens.cc would give. Any ideas, or is there something I missed?

IronBits
04-05-2003, 11:00 PM
Try this in your Vhosts.conf

UseCanonicalName On
NameVirtualHost *
<VirtualHost *>
ServerName soitgoes.dbestern.net
DocumentRoot /var/www/html/soitgoes
ScriptAlias /cgi-bin/ /var/www/cgi-bin/soitgoes/
CustomLog logs/access_log_soitgoes combined
ErrorLog logs/error_log_soitgoes
</VirtualHost>
:D

magnav0x
04-05-2003, 11:55 PM
Hrm well the subdomains "appear" to work properly. The problem is they all seem to mirror each other.

UseCanonicalName On
NameVirtualHost *
<VirtualHost *>
ServerName test.technosapiens.cc
DocumentRoot c:/phpweb/users/test
CustomLog logs/access_log_soitgoes combined
ErrorLog logs/error_log_soitgoes
</VirtualHost>

I loaded put my statistics stuff in c:/phpweb/users/test, but when I goto test.technosapiens.cc I get the exact same thing as www.technosapiens.cc which is located in c:/phpweb. So I tryed just putting a index.html in c:/phpweb/users/test and loading http://test.technosapiens.cc. Great it show's "test", but when I goto www.technosapiens.cc it show's "test" instead of the postnuke site that is located in c:/phpweb. I have a migrane the size of Iraq! :swear:

magnav0x
04-06-2003, 01:07 AM
I've just come to the conclusion that virtual hosts WILL not work in windows, and I refuse to use IIS. Time to set up a dedicated linux webserver.

IronBits
04-06-2003, 03:02 AM
Try the Mandrake 9.1 - it's easy to work with and rock solid. :D

the-mk
04-06-2003, 04:10 AM
Virtual hosts will work on windows. I've tried and it works fine for me. Perhaps you could read http://httpd.apache.org/docs-2.0/vhosts/ or http://httpd.apache.org/docs/vhosts/index.html first. It helped me a lot. Virtual hosts work at windows and linux at my home rock-stable.

I'm doing name-based (one ip, more hosts) virtualhosts at home. My config-code of my httpd.conf:


. . .
NameVirtualHost *

<VirtualHost *>
DocumentRoot /data/web/http-root
ServerName the-mk.dyndns.org
ErrorLog /var/log/httpd/themk_error_log
CustomLog /var/log/httpd/themk_access_log combined
</VirtualHost>

<VirtualHost *>
DocumentRoot /data/web/http-root2
ServerName stats.the-mk.dyndns.org
ErrorLog /var/log/httpd/stats_error_log
CustomLog /var/log/httpd/stats_access_log combined
</VirtualHost>
. . .


My first virtual hosts is the "standard"-webfolder (like your www.technosapiens.cc) and the second virtual host should be test.technosapiens.cc or whatever you like.

You don't need to setup a linux for that, but I think that linux is much better than windows for that :D

magnav0x
04-06-2003, 01:33 PM
Hrm, so your setup there is on a windows machine? What would your absolute path be to DocumentRoot /data/web/http-root? The root of my webserver is c:/phpweb. Would that make it just /phpweb in the documentroot for viruatl hosts or would it just be / ? That may be what is causing me problems, the way I syntax the document roots.

I've read all the documentation on virutal hosts, but I came up with the same results every time (sub domain mirroring the regular www domain.).

the-mk
04-06-2003, 01:55 PM
:crazy: Sorry for confusing you. The configuration above is one of a linux-machine. But I've tried it on a windows-machine too and it worked fine for me.

I would say that you try the following configuration (on a windows-machine):


. . .
UseCanonicalName On
NameVirtualHost *

<VirtualHost *>
DocumentRoot c:\phpweb
ServerName www.technosapiens.cc
# and whatever you need
</VirtualHost>
<VirtualHost *>
DocumentRoot c:\phpweb\users\test
ServerName test.technosapiens.cc
# and whatever you need
</VirtualHost>
. . .


If it works, it's fine, if not then I don't know what the problem could be.

magnav0x
04-06-2003, 02:37 PM
Well I did it like that and got the same results. If I put a index.html in the test folder (domain) it will display the word "test" on the page at test.technosapiens.cc and if I goto www.technosapiens.cc I get the postnuke site. Which is great, but as soon as I put in my php statistics into the test folder and bring up stats.technosapiens.cc I get the postnuke index.php instead of the stats index.php. Odd enough, I think I've given it enough thought and I can't figure it out. Earlier this morning I ran accross a page that said Virtual Hosts in fact did not work on Windows via Apache, but it was dated back to 2000. I guess Apache never felt the need to fix this, or I'm just not doing something right.

IronBits
04-06-2003, 02:38 PM
I seem to remember there is a line you have to comment out in the config file to enable it to use virtual hosts ....

the-mk
04-06-2003, 02:54 PM
Some questions:
- what version of apache are you using (I used 2.0.43 on my windows-machine)
- do you have a virtual-hosts-entry for "stats.technosapiens.cc"? (why I ask: if there is no entry apache takes as default the first virtualhost entry; as I see you have a "www", a "test" and a "stats" subdomain for technosapiens.cc and for every subdomain you need a virtualhost entry)
- what is that "UseCanonicalName On" for?

magnav0x
04-06-2003, 03:09 PM
I'm using Apache 2.0.45, I have a virtual host for all subdomains, with www listed first (default). I've since gotten rid of UseCanonicalName, because it's just for using shortcut urls on a lan. e.g. "stats" would goto stats.technosapiens.cc, but I have no need for it since I can't get them to display the correct stuff. I was thinking, maybe it's some sort of cachine problem, because index.html will display it's stuff just fine, but index.php would display www's index.php instead of it's own?