xampp配置虚拟主机的步骤
一.配置httpd.conf
在安装了xampp的文件夹内依次找到下面的目录 eg: D:\xampp\apache\conf
打开httpd.conf文件
1.这是xampp的文件地址:
Define SRVROOT "D:/xampp/apache"
ServerRoot "D:/xampp/apache"
2.可以自定义修改的监听端口:
Listen 80
3.修改成你想要访问的文件的地址
DocumentRoot "C:/Users/zengzhi/Desktop/www"
<Directory "C:/Users/zengzhi/Desktop/www">
二.配置httpd-vhosts.conf文件
从安装xampp的文件夹内依次访问 eg:D:\xampp\apache\conf\extra 打开httpd-vhosts.conf文件
按照他所提示的内容进行修改:
##<VirtualHost *:80>
##ServerAdmin [email protected]
##DocumentRoot "D:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>
修改后:
<VirtualHost *:80>
##ServerAdmin [email protected]/dummy-host.example.com
DocumentRoot "C:/Users/zengzhi/Desktop/www" //文件路径
ServerName www.io //自定义本地域名
##ErrorLog "logs/logs/dummy-host.example.com-error.log"
##CustomLog "logs/logs/dummy-host.example.com-access.log" common
</VirtualHost>
三.配置hosts文件添加本地域名
进入一下目录 C:\Windows\System32\drivers\etc
1.点击hosts属性
2.点击安全 选中users
3.点击编辑 选中users 在完全控制上点勾 √
4.通过记事本打开hosts文件
获取自己的ipv4地址( 控制面板\网络和 Internet\网络和共享中心 )
给本地添加域名
然后通过在网址上输入域名就完成了!