- 论坛徽章:
- 0
|
✦ Name-based: Name-based virtual Web sites are very common. Such a configu-
ration requires that you have multiple hostnames pointed to a single system.
You can create multiple CNAME or A records in DNS to point to a single host.
Because this method does not use IP addresses in Apache configuration, it is
easy to port if you change your IP addresses for your Web server.
For example, say you have IP address 192.168.1.100 and want to host
vhost1.domain.com and vhost2.domain.com on the same server. Here’s how you
can do that:
1. First create the appropriate DNS records on your DNS server to point to
vhost1.domain.com and vhost2.domain.com to 192.168.1.100. See the
“Configuring DNS for a Virtual Host”section for details.
2. Create a configuration segment similar to the following in the httpd.conf file.
NameVirtualHost 192.168.1.100
<VirtualHost 192.168.1.100>
ServerName vhost1.domain.com
ServerAdmin someone@vhost1.domain.com
DocumentRoot “/www/vhost1/htdocs”
#
# Any other directives you need can go here
</VirtualHost>
<VirtualHost 192.168.1.100>
ServerName vhost2.domain.com
ServerAdmin someone@vhost2.domain.com
DocumentRoot “/www/vhost2/htdocs”
#
# Any other directives you need can go here
#
</VirtualHost>
Don’t forget to create the document root directories if you don’t have them
already. Also, if you need to add more directives in each of the virtual host
configuration you can do so. |
|