[CentOS] virtual host on latest centos 4.4
Will McDonald
wmcdonald at gmail.com
Fri Oct 6 09:41:22 UTC 2006
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.
More information about the CentOS
mailing list