Chapter 3. Getting started
entitled to update the sites.
# cd /var/www
# mkdir CHALK CHEESE
# groupadd -r chalk
# groupadd -r cheese
# chgrp chalk CHALK
# chgrp cheese CHEESE
# chmod g+ws CHALK
# chmod g+ws CHEESE
Figure 3-11. Setting up the two web sites
To let us know we have reached the right directory we will put a file, index.html in
each directory identifying it.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>The CHALK web site</title>
</head><body>
<h1>Welcome to CHALK</h1>
<p>This is the CHALK web site.</p>
</body>
</html>
Figure 3-12. The chalk index.html file
Now we must tell the web server to use these two directories appropriately.
NameVirtualHost *
<VirtualHost *>
ServerName chalk.dept.cam.ac.uk
DocumentRoot /var/www/CHALK
</VirtualHost>
<VirtualHost *>
ServerName cheese.dept.cam.ac.uk
DocumentRoot /var/www/CHEESE
</VirtualHost>
Figure 3-13. httpd.conf: Setting up the virtual hosts
To set up a named-based virtual host we add a section like the one shown in the
figure above to the configuration file. Two such sections should be added, one for
chalk and one for cheese. So what does it mean?
Syntax summary: Virtual hosts
NameVirtualHost interface
This instructs the web server to run name-based virtual hosts on interface. If
the specified interface is * then all available interfaces are used.
<VirtualHost>
The VirtualHost section describes a single virtual host. Everything from the
<VirtualHost interface> to </VirtualHost> sets parameters for a single vir-
tual host. The interface specified must match one previously set up for named-
based virtual hosting by a NameVirtualHost command.
19
Comentarios a estos manuales