1.打开httpd.conf文件(/etc/httpd/conf)
2.找到#Include conf/extra/httpd-vhosts.conf这句,将之前的#号去掉,开启虚拟主机配置。如果没有找到#Include conf/extra/httpd-vhosts.conf这句,则找到虚拟主机配置文件路径,在httpd.conf中添加”Include 虚拟主机配置文件路径”。
3.编辑虚拟主机配置文件(/usr/share/doc/httpd-2.4/httpd-vhosts.conf)
<VirtualHost *:80> ServerAdmin webmaster@dummy-host1.example.com DocumentRoot "/Apache24/docs/dummy-host1.example.com" ServerName dummy-host1.example.com ServerAlias www.dummy-host1.example.com ErrorLog "logs/dummy-host1.example.com-error.log" CustomLog "logs/dummy-host1.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/Apache24/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ServerAlias www.dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
4.编辑hosts文件(/etc/hosts)
在hosts文件中添加以下内容: 127.0.0.1 ser1.com 127.0.0.1 ser2.com
5.重启服务器:service httpd restart到此多站点配置完成
来源:lonelyworld.cn
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。