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