1 Apache虚拟主机的实现方式有3种。
- 基于IP的虚拟主机
- 基于端口的虚拟主机
- 基于域名的虚拟主机
2.1基于域名的虚拟主机
打开apache\apache2.4.9\conf\extra文件目录下的 httpd-vhosts.conf
增加
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "c:/Apache24/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com // DocumentRoot "E:/WWW/blogdemo2-master" ServerName jizi.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
常见错误
配置好域名之后出现同一域名指向根目录