Click to See Complete Forum and Search --> : 2+ sites in one server - How?!


Junior G.
04-03-2002, 10:40 AM
Hello all,

I have just set up an Apache Server on my Mandrake 8.0 box.
I would like to add a Virtual Host to this server, but I'm having a bit of trouble.
I have 2 files to configure this server. The httpd.conf file which holds the Server Configuration and vhosts.conf, which holds configuration for Virtual Hosts.
I have copied the configuration info from these 2 files below for you to see.
At present, I can connect to the Web Site created by default when I installed Apache, but I cannot connect to my Virtual Web Site.

Also, can you please tell me how can I connect to a Web Site by using the server Hostname instead of the IP Address.
I can connect to my default web site from Linux using either the Hostname or IP Address, but when I try to connect to it using any Windows Client, I'm only able to connect using the IP Address. Using the Hostname, I get an Error: "The requested URL could not be retrieved".

Any advise would be gratefully received.

Thanks

Config Files...

httpd.conf
### Main Configuration Section
### You really shouldn't change these settings unless you're a guru
###
ServerName MYServer
ServerType standalone
ServerRoot /etc/httpd
#ServerName localhost
#LockFile /etc/httpd/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile /etc/httpd/httpd.scoreboard
ErrorLog logs/error_log
LogLevel warn
ResourceConfig /dev/null
AccessConfig /dev/null
ServerAdmin root@localhost
HostnameLookups On
DocumentRoot /var/www/html
NameVirtualHost aaa.bbb.0.0

vhosts.conf#
<VirtualHost aaa.bbb.27.254>
ServerAdmin root@localhost
DocumentRoot /samba/fcrteam
ServerName fcrteam.com
HostNameLookups On
ServerAlias fcrteam
</VirtualHost>

chikn
04-03-2002, 11:20 AM
You should have a line like this in httpd.conf

Include conf/vhosts/Vhosts.conf

And your vhosts should look similar to this.


################# Named VirtualHosts
NameVirtualHost 24.199.xxx.xx

<VirtualHost 24.199.xxx.xx>
ServerName mail.website.com
ServerPath /home/website
DocumentRoot /var/website/html
Options ExecCgi Includes
SSLVerifyClient none
</VirtualHost>

<VirtualHost 24.199.xxx.xx>
ServerName mail.website1.com
ServerPath /home/website1
DocumentRoot /home/website1/web
ScriptAlias /cgi-bin/ /home/website/cgi-bin/
Options ExecCgi Includes
</VirtualHost>

And as far as it not showing the right site from another computer would probably either be a config error in apache but it sounds like you have no DNS entry the site.

[ 03 April 2002: Message edited by: chikn ]

Junior G.
04-03-2002, 03:43 PM
Hello,
Sorry for the late response.
I do have that line (Include conf/vhosts/vhosts.conf) in my httpd.conf file. Sorry, I forgot to mention that earlier.

I however, do not have the line (NameVirtualHost aaa.bbb.0.0) in my vhosts.conf file. I have it in my httpd.conf file instead.
I will reconfigure my files and let you know how I get on.

Thanks very much for your help.

PS: So, can I have several Virtual Hosts served from my box using just one IP Address?
For example, let say that my Mandrake 8.0 box has an IP Address of 10.0.0.1, which I can use to connect to my Default Web Site.
Can I use the same address in my vhosts.conf file to setup other Web Sites?
Like this...

NameVirtualHost 10.0.0.1

<VirtualHost 10.0.0.1>
ServerName server1.domain.com
ServerPath /home/server1
DocumentRoot /var/server1/html
HostNameLookups On
</VirtualHost>

<VirtualHost 10.0.0.1>
ServerName server2.domain.com
ServerPath /home/server2
DocumentRoot /var/server2/html
HostNameLookups On
</VirtualHost>

Also, just to let you know, we have DNS and WINS in our network and I can see the Linux Server from Windows (Connecting to it by Hostname), but cannot connect to the Apache Server with Hostname. Anything else you can think of? Do I need to specify the Machine Name somewhere in httpd.conf or other Config File within Apache?

Thanks again

chikn
04-03-2002, 07:15 PM
NameVirtualHost 10.0.0.1

<VirtualHost 10.0.0.1>
ServerName server1.domain.com
ServerPath /home/server1
DocumentRoot /var/server1/html
HostNameLookups On
</VirtualHost>

<VirtualHost 10.0.0.1>
ServerName server2.domain.com
ServerPath /home/server2
DocumentRoot /var/server2/html
HostNameLookups On
</VirtualHost>


Well entries like those are good and yes I know of no limit as to how many name based vhosts off 1 IP, I currently have 22 running off the same IP.


If you have DNS entries for each domain name then Apache should without any configuration interpret the header. Also the docs say do it so I always do when I add more vhosts to the file. Did you make any other changes to the httpd.conf file that migh be causing apache not to function correctly?

#postmap Vhosts.conf

Junior G.
04-04-2002, 02:23 AM
Hi chikn,
I actually do not have any DNS Entries for my Virtual Servers. Where do I add these entries? on my Network DNS (which runs off a Win2K Server) or do I add them somewhere in Linux (/etc/hosts maybe!).

Thanks again for your valuable help!.

chikn
04-04-2002, 08:04 AM
Originally posted by Junior G.:
<STRONG>Hi chikn,
I actually do not have any DNS Entries for my Virtual Servers. Where do I add these entries? on my Network DNS (which runs off a Win2K Server) or do I add them somewhere in Linux (/etc/hosts maybe!).

Thanks again for your valuable help!.</STRONG>

You need to make DNS entries in your 2k DNS server.

Junior G.
04-04-2002, 10:20 AM
Hi chikn,

Thanks a million for your valuable help.
I will be adding the entries to the DNS Servers today and hopefully that will do the trick.

Thanks again.

Kind regards

Junior G.
04-05-2002, 03:11 AM
Hi chikn,
Just to let you know that I have added the DNS entries of my Virtual Servers to my Win2K DNS Server and I can now access them from anywhere on my network (By hostname!!).

Thanks a million!