Forum Moderators: phranque

Message Too Old, No Replies

cant get virtual host to work

         

philosophos

10:08 am on Jun 19, 2004 (gmt 0)

10+ Year Member



i tried to get virtual host to work (apache 2.0.49). i used the same conf like i did in 2.0.46. but now if i try to enter the page... i just get a "Index /" :-(

why is that? what im doing wrong? please help

<VirtualHost *>
ServerName www.example.de
ServerAlias example.de
ScriptAlias /cgi-bin/ /home/gluswul/public_html/cgi-bin/
ServerAdmin admin@example.de
DocumentRoot /home/gluswul/public_html/
ErrorLog /home/gluswul/wwwlogs/error_log
LogLevel warn
LogFormat "%h %t \"%r\" \"%{User-agent}i\" %>s %b (%{Referer}i)" common
CustomLog /home/gluswul/wwwlogs/access_log common
</VirtualHost>

[edited by: jdMorgan at 2:02 pm (utc) on June 19, 2004]
[edit reason] Removed specifics per TOS [/edit]

philosophos

10:31 am on Jun 19, 2004 (gmt 0)

10+ Year Member



just to add. i found out something. maybe significant.

the ****ing apache just seems to load the same documentroot for alle vhosts ... why is that? i tried it
with 2 config file for 2 virtual hosts. both should be loading diffrent documentroots, but they didnt. www.example.de points to /home/****/public_html/ and www.quux-foo.org points to another user, but both seems to point to the same (the first user)... quux-foo.org has two virtual hosts.. www.quux-foo.org and amy.quux-foo.org ... but they all seems to point to www.example.de (or his document root)... if i delete the vhost andreas... the both points to www.quux-foo.org ... i cant get more than one virtual host up the same time! but why?! it worked before, why not now?

[edited by: jdMorgan at 2:03 pm (utc) on June 19, 2004]
[edit reason] Removed speciifics per TOS [/edit]

hct224

5:31 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



you may need to add port 80 to virtual host.


<virtualHost1 *:80>
DocumentRoot /path/to/VH1
.....
</virtualHost>

<virtualHost2 *:80>
DocumentRoot /path/to/VH2
.....
</virtualHost>

Zych

9:54 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



I am having the same problem with the Windows version. I thought I was going crazy. I am new to Apache (just downloaded it yesterday). If this is a confirmed bug please let me know. For reference here is my VH section of my conf file:

# Use name-based virtual hosting.
#
NameVirtualHost 192.168.2.230:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost 192.168.2.230:80>
ServerAdmin admin@localhost
DocumentRoot "c:/www/example"
ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>
<VirtualHost 192.168.2.230:80>
ServerAdmin Admin@example.com
DocumentRoot "C:/www/example"
ServerName example.com
ServerAlias *.example.com
ErrorLog logs/example-error.log
CustomLog logs/example-access.log common
<Directory "C:/www/example">
Options All Includes Indexes
</Directory>
</VirtualHost>

[edited by: jdMorgan at 2:53 pm (utc) on June 24, 2004]
[edit reason] Removed specifics per TOS [/edit]

gergoe

10:21 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



localhost is a separate interface in itself, with a different ip address of course, so you need to handle it separately from the other ip addresses. Depending on what you want to do (you seems to forgot to tell us) you need to change your configuration files.

Try adding a new NameVirtualHost directive with the 127.0.0.1 along the other one, take out the port definition (:80) -I don't really think you need it- and change the attribute of the VirtualHost to *, so they will look like this:


<VirtualHost *>
...
</VirtualHost>

By doing these changes you will be able to use name based virtual hosting on localhost (by changing the <i>hosts</i> file on your computer) and on the ip addresses you specify with the NameVirtualHost directive.

Zych

12:57 am on Jun 23, 2004 (gmt 0)

10+ Year Member



I have tried this using IP also and it does not work. I think it may be a bug in the latest release unless somebody can verify that they are using the latest and it is working with virtual hosts. You can see some other posts I made in another forum here:

[tek-tips.com...]

- Zych

hct224

1:13 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



Zych,
You are pointing 2 virtual hosts in a same directory which are causing the problem. Look at line:
DocumentRoot "c:/www/example" in both virtual hosts.
You should change to something like:
<VirtualHost 1>
......
DocumentRoot "c:/www/example1"
................
</VirtualHost>
<VirtualHost 1>
......
DocumentRoot "c:/www/example2"
................
</VirtualHost>

[edited by: jdMorgan at 2:55 pm (utc) on June 24, 2004]
[edit reason] Removed specifics per TOS [/edit]

Zych

8:47 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



In this case I was just trying to see if I could get anything but the default page to come up. I have tried it pointing to other directories but it still does not work. (In fact I just changed it and then restarted Apache to no avail.)
I also tried it both with IP Address and Name based but neither works. Has anyone got this to work with Apache 2.0.49? At least that way I would know if it is a version problem or something I am doing wrong.

gergoe

10:07 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



If the directories are the same you can not see the difference between the different virtualhost (even when it is working properly), so I suggest you to use a different directory for each of them. Use a config like this to make the virtual hosting based on the hostnames only:

NameVirtualHost *
<VirtualHost *>
ServerName domain1.com
DocumentRoot "C:/www/[b]domain1[/b]"
</VirtualHost>
<VirtualHost *>
ServerName domain2.com
DocumentRoot "C:/www/[b]domain2[/b]"
</VirtualHost>
<VirtualHost *>
ServerName localhost
DocumentRoot "c:/www/[b]localhost[/b]"
</VirtualHost>

...or use this one for ip and name based virtual hosting (you need this if you use [localhost...] like addresses only for internal purposes):

NameVirtualHost 192.168.2.230
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "c:/www/[b]localhost[/b]"
</VirtualHost>
<VirtualHost 192.168.2.230>
ServerName domain1.com
DocumentRoot "C:/www/[b]domain1[/b]"
</VirtualHost>
<VirtualHost 192.168.2.230>
ServerName domain2.com
DocumentRoot "C:/www/[b]domain2[/b]"
</VirtualHost>

If you are in doubt, try the apache -S command from the command line to see the virtual host setup of the apache.

Zych

12:49 am on Jun 24, 2004 (gmt 0)

10+ Year Member



I'll look into the Apache -S This may be helpful. As for the directories being the same I did that on purpose. The problem is that it never shows what is in that directory. It always showed the Apache default screen. This is the screen that would come up if you just set it up without any options.

Can I install an older version of Apache over this newer one to test that out? or do I need to completely remove this version then do a reinstall?

Hey philosophos: Did you ever get yours to work?

Thanks,

Zych

gergoe

10:39 am on Jun 24, 2004 (gmt 0)

10+ Year Member



Personally I did not use apache 2 yet, because of other reasons, but I hardly ever belive that the guys at apache releases an apache where the virtual hosting is not working properly.

Take a look in the [httpd.apache.org...] page, it might give you a hint on what you are doing wrong.

Zych

9:47 pm on Jun 24, 2004 (gmt 0)

10+ Year Member



OK. It looks like the bug was me. I had forgotten that I installed Zone Alarm since I used this system for the initial install of my Internet connection. It appears, even though I am on the same machine, that it disables this part of Apache. It works fine if I shut it down. Sorry to make you guys run around like that for a stupid error on my part.

- Zych