apache搭建虚拟主机有两方法。
第一步完成apache虚拟目录配置;
第二步到httd.conf里面找到
# Virtual hosts 虚拟主机
Include conf/extra/httpd-vhosts.conf
找到后去掉#注释.
第三步打开 conf/extra/httpd-vhosts.conf 文件
接下来有两种配置方法。
1-添加下面代码
- <VirtualHost *:80>
- ServerAdmin webmaster@dummy-host.example.com
- DocumentRoot "D:/myblog" //这里的d就是你虚拟目录的位置了
- ServerName www.lengai.com //这里是你要映射的域名
- ErrorLog "logs/demo.neoease.com-error.log"
- CustomLog "logs/demo.neoease.com-access.log" common
- </VirtualHost>
重启apache就ok了.
2-添加下面代码
- <VirtualHost 127.0.0.1:80> //这里的ip地址要注意。这样配置其他电脑是连接不到的。必须改为网卡地址。
- DocumentRoot "D:/myblog" //虚拟目录地址
- DirectoryIndex index.html index.htm index.php
- <Directory /> //权限
- Options FollowSymLinks
- Allowoverride None
- order Allow,deny
- Allow from all
- </Directory>
- </VirtualHost>
重启apache可以了
个人更喜欢第一种方法。
转载于:https://blog.51cto.com/lengai/1172474