Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache VHosts Problem

Status
Not open for further replies.

vBean

Programmer
Jun 13, 2003
12
0
0
US
Using Win 2000 Server and Apache 2

I am trying to host my sites on an alternate port, using :8787 instead of :80. I use DNS2GO for my dynamic IP resoulution, and I made a setting in each of my domain names to "forward requests to same IP but on this port: 8787". My problem is that all requests to my server bring up my default domain content (the first vhost in the list), here is my apache config:

Code:
Listen *:8787

NameVirtualHost *:8787

#
#These are main sites
#

<VirtualHost *:8787>
ServerName [URL unfurl="true"]www.siteone.com[/URL]
ServerAlias siteone.com
ServerAdmin webmaster@siteone.com
DocumentRoot C:/sites/siteone
CustomLog C:/sites/siteone/sitelog.log "%h %o %l %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"
Options -Indexes
</VirtualHost>

<VirtualHost *:8787>
ServerName [URL unfurl="true"]www.sitetwo.com[/URL]
ServerAlias sitetwo.com
DocumentRoot C:/sites/sitetwo
CustomLog C:/sites/logs/sitetwo_site.log "%h %l %u %t\"%r\" %s %b\"%{Referer}i\" \"%{User-Agent}i\""
Options -Indexes
</VirtualHost>

also, when I make changes to my apache fonfig, do I need to just retart apache or should I reboot?

tia for any assistance...
 
vBean,

I would change the Listen directive to
Listen 8787
and place quotes around the DocumentRoot paths in your VirtualHost containers.
DocumentRoot "C:/sites/siteone"

The ServerName and ServerAlias directives within the same VirtualHost container may be causing some confusion. I would comment out the ServerAlias directives.
# ServerAlias siteone.com

When making changes to your httpd.conf, you only need to restart Apache, not reboot.
apache -k restart

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
vbean;
I'm trying to do the same thing, to no avail. I do know however, that the default virtual host has to have the same ServerName and DocumentRoot as the original server. I think this includes the port in The ServerName, so look at the original ServerName in the 'conf' file, and then make your default virtual host the very same.
And there is in issue of virtual hosting not working if you're running SSL, which I think is my problem.

If you get it working, can you let me know what the problem was on this thread?

TIA.
 
Hummm, dynamic IPs and vhosting. I think that is actually the problem. I have found that using the wild character * is something that apache doesn't like when it comes to vhosts. It will always kick to the default server conf.

An example of my running vhost.conf file is shown below:

Code:
NameVirtualHost 67.41.19X.XXX:80

    <VirtualHost 67.41.19X.XXX:80>
    ServerName [URL unfurl="true"]www.XXX.com[/URL]
    DocumentRoot /var/[URL unfurl="true"]www/XXX[/URL]
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog /var/[URL unfurl="true"]www/logs/access.XXX.com.txt[/URL] combined
    </VirtualHost>

    <VirtualHost 67.41.19X.XXX:80>
    ServerName [URL unfurl="true"]www.XXX.us[/URL]
    DocumentRoot /var/[URL unfurl="true"]www/html[/URL]
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog /var/[URL unfurl="true"]www/logs/access.XXX.us.txt[/URL] combined
    </VirtualHost>

    <VirtualHost 67.41.19X.XXX:80>
    ServerName dev.XXX.us
    DocumentRoot /var/[URL unfurl="true"]www/XXX[/URL]
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog /var/[URL unfurl="true"]www/logs/access.XXX.us.txt[/URL] combined
    </VirtualHost>

If you are not able to obtain a static IP it may be an up-hill battle. If you resolve the issue with the advice from the above post congrats!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top