Good morning All, I have a slight issue with apache virtual hosts not working on my newly installed CentOS (4.4). I am very new to Linux, however I have experience with apache etc on 'w1nd0ws'. I've been round and round in the apache conf file and to no avail. Basically if I setup a virtual host the default then looks at it. Also, if I setup multiple virtual hosts they all look at the first virtual host. I'm running the machine inside my local network as a staging server for web design. I then set my HOSTS file on my PC to the ip of the server and then the www.domain.co.uk: Eg: 192.168.1.250 www.testsiteonvirtualhost.co.uk This is what I do on my other apache test server (not CentOS). I assume this should work?? Is there anything other than virtual hosts that would need setting up?? Thanks in advance. Mark.
Coming from Windows, you are probably more used to administering things from a GUI, rather than a CLI. Have you tried using system-config-httpd yet? You should find this _very_ easy to setup virtual hosts with.
Mark Fitzsimmons wrote:> Good morning All, > > I have a slight issue with apache virtual hosts not working on my newly > installed CentOS (4.4).I doubt this is a CentOS problem. Consider this: http://www.catb.org/~esr/faqs/smart-questions.html#forum I will nonetheless try to help you.> I am very new to Linux, however I have experience with apache etc on > 'w1nd0ws'. I've been round and round in the apache conf file and to no > avail. > > Basically if I setup a virtual host the default then looks at it. Also, > if I setup multiple virtual hosts they all look at the first virtual > host.The first vhost is supposed to be the default. The subsequent vhosts are used if the requested URI reported by the browser matches a ServerName or ServerAlias directive. If none matches, the first is used.> I'm running the machine inside my local network as a staging server for > web design. I then set my HOSTS file on my PC to the ip of the server > and then the www.domain.co.uk: > > Eg: > 192.168.1.250 www.testsiteonvirtualhost.co.uk > > This is what I do on my other apache test server (not CentOS). I assume > this should work??I think so. Entering that site into the address bar of your browser should bring up the corresponding vhost. Try running the 'apachectl -S' command. This will give you information about your vhosts, and check the syntac of your apache configuration.> Is there anything other than virtual hosts that would need setting up??That's a very broad question ;P You might want to be sure that you know what's being called from the /etc/httpd/conf.d/ configuration files. I don't know what the default CentOS files look like, but sometimes there's a 'vhosts.conf' file in there that might be confusing things. JT
On Fri, 6 Oct 2006, Mark Fitzsimmons wrote:> Good morning All, > > I have a slight issue with apache virtual hosts not working on my newly > installed CentOS (4.4). > > I am very new to Linux, however I have experience with apache etc on > 'w1nd0ws'. I've been round and round in the apache conf file and to no > avail. > > Basically if I setup a virtual host the default then looks at it. Also, > if I setup multiple virtual hosts they all look at the first virtual > host.The default is expected to be the first virtual host, but it seems like you dont have the correct config for the virtual hosts. You can check the config using /usr/sbin/httpd -S that will tell you what the virtual hosts are set up as. I assume from what you say that you are restarting apache after changing the config.> > I'm running the machine inside my local network as a staging server for > web design. I then set my HOSTS file on my PC to the ip of the server > and then the www.domain.co.uk: > > Eg: > 192.168.1.250 www.testsiteonvirtualhost.co.uk > > This is what I do on my other apache test server (not CentOS). I assume > this should work??Seems like it ought to - do you get the correct ip address with dig ?? or can you ping www.testsiteonvirtualhost.co.uk and do web accesses show in logs on the server.> > Is there anything other than virtual hosts that would need setting up??Not usually - you want want to paste your virtualhost config here ... Regards Lance -- uklinux.net - The ISP of choice for the discerning Linux user.
He he.. yes, my Windows background does steer me to GUI interfaces. I have added rpmforge to YUM so I could install webmin to help me out. :-)) I'll try 'system-config-httpd' thanks. -----Original Message----- From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On Behalf Of DamianS Sent: 06 October 2006 10:09 To: CentOS mailing list Subject: Re: [CentOS] virtual host on latest centos 4.4 Coming from Windows, you are probably more used to administering things from a GUI, rather than a CLI. Have you tried using system-config-httpd yet? You should find this _very_ easy to setup virtual hosts with. _______________________________________________ CentOS mailing list CentOS at centos.org http://lists.centos.org/mailman/listinfo/centos
On 06/10/06, Mark Fitzsimmons <Mark at xigen.co.uk> wrote:> Good morning All, > > I have a slight issue with apache virtual hosts not working on my newly > installed CentOS (4.4). > > I am very new to Linux, however I have experience with apache etc on > 'w1nd0ws'. I've been round and round in the apache conf file and to no > avail. > > Basically if I setup a virtual host the default then looks at it. Also, > if I setup multiple virtual hosts they all look at the first virtual > host. > > I'm running the machine inside my local network as a staging server for > web design. I then set my HOSTS file on my PC to the ip of the server > and then the www.domain.co.uk: > > Eg: > 192.168.1.250 www.testsiteonvirtualhost.co.uk > > This is what I do on my other apache test server (not CentOS). I assume > this should work?? > > Is there anything other than virtual hosts that would need setting up?? >Here's how I setup Name-based Virtual Hosts. Assuming a vanilla Apache config, in /etc/httpd/conf/httpd.conf I add at the bottom... # Individual sites' name-based vhost configurations are in # /etc/httpd/conf.d/dev.*.conf # # NameVirtualHost for base site NameVirtualHost 192.168.24.120:80 # Define default catch-all vhost containers for requests # which don't match any other containers defined in conf.d/ <VirtualHost 192.168.24.120:80> ServerName webserv1 DocumentRoot /var/www/html/ </VirtualHost> Then in /etc/httpd/conf.d/ I would have a file dev.site1.conf for example containing <VirtualHost 192.168.24.120:80> ServerName www.site1.co.uk ServerAdmin webmaster at site1.co.uk DocumentRoot /home/site1/public_html/ RewriteEngine on RewriteCond %{REQUEST_METHOD} ^TRACE RewriteRule .* - [F] ErrorLog /home/site1/logs/error_log TransferLog /home/site1/logs/access_log CustomLog /home/site1/logs/custom_log combined ScriptAlias /cgi-bin/ /home/site1/cgi-bin/ <Directory "/home/site1/cgi-bin/"> Options +ExecCGI </Directory> </VirtualHost> Copy and replace site1 for site2 in /etc/httpd/conf.d/dev.site2.conf and so on. Will.
Resolved. Wow I can't believe it, I spent hours on that! I think the fact that the default site used the first virtual host was spinning me out. I've rebooted the server and also added another vhost and all is good. The second vhost is fine. FYI my vhost look like this: ------------ NameVirtualHost 192.168.1.250 <VirtualHost 192.168.1.250> suPHP_UserGroup cremaster users ServerAdmin support at xigen.co.uk ServerName www.cre.co.uk ServerAlias cre.co.uk DocumentRoot /secure/c/cre.co.uk Alias /logs /webstats/c/cre.co.uk/webalizer </VirtualHost> <VirtualHost 192.168.1.250> suPHP_UserGroup cremaster2 users ServerAdmin support at xigen.co.uk ServerName www.cre2.co.uk ServerAlias cre2.co.uk DocumentRoot /secure/c/cre2.co.uk Alias /logs /webstats/c/cre2.co.uk/webalizer </VirtualHost> ------------- Thanks all for your Help, I hope I can help someone out later sometime. Mark.