1.基于IP地址的虚拟主机
ServerName 192.168.16.201:80
ServerAdmin web1@163.com
DocumentRoot "/usr/www/web1"
DirectoryIndex index.html
ErrorLog logs/web1/error_log
CustomLog logs/web1/access_log combined
ServerName 192.168.16.202:80
ServerAdmin web2@163.com
DocumentRoot "/usr/www/web2"
DirectoryIndex default.html
ErrorLog logs/web2/error_log
CustomLog logs/web2/access_log combined
2. 基于域名的虚拟主机
当Web服务器收到访问请求时,就可以根据不同的DNS域名来访问不同的网站。它的优势就是不需要更多的IP地址,容易配置。
NameVirtualHost 192.168.16.201
ServerName :80
ServerAdmin web1@163.com
DocumentRoot "/usr/www/web1"
DirectoryIndex index.html
ErrorLog logs/web1/error_log
CustomLog logs/web1/access_log combined
ServerName
ServerAdmin web2@163.com
DocumentRoot "/usr/www/web2"
DirectoryIndex default.html
ErrorLog logs/web2/error_log
CustomLog logs/web2/access_log combined
3. 基于端口的配置
Listen 80
Listen 81
ServerName 192.168.16.201:80
ServerAdmin web1@163.com
DocumentRoot "/usr/www/web1"
DirectoryIndex index.html
ErrorLog logs/web1/error_log
CustomLog logs/web1/access_log combined
ServerName 192.168.16.201:81
ServerAdmin web2@163.com
DocumentRoot "/usr/www/web2"
DirectoryIndex default.html
ErrorLog logs/web2/error_log
CustomLog logs/web2/access_log combined
阅读(479) | 评论(0) | 转发(0) |