1.find / -name httpd.conf
找到httpd的位置
2.打開httpd.conf
修改(沒有就自己添加)
ServerName192.168.1.103:80?
NameVirtualHost?192.168.1.103
3.在底部添加
<VirtualHost192.168.1.103>
ServerAdmin root@localhost
DocumentRoot /var/www/html/exp1
ServerName?example1.com
</VirtualHost>
<VirtualHost192.168.1.103>
ServerAdmin root@localhost
DocumentRoot /var/www/html/exp2
ServerName?example2.com
</VirtualHost>
4.重啟動(dòng)apache? ? service httpd?restart
5.打開你電腦(window)的host文件?C:\Windows\System32\drivers\etc\host
192.168.1.103? example1.com
192.168.1.103? example2.com