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.
On 06/10/06, Mark Fitzsimmons Mark@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@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.