我爱编程

Apache常用虚拟主机配置

2017-09-17  本文已影响0人  RiverCrab

1.虚拟主机概念

2.配置虚拟主机

第一步: 在httpd.conf文件加载虚拟主机配置文件

apache/conf/httpd.conf 在这个文件中,我们搜索 httpd-vhost
去除第二行的#号

# Virtual hosts
Include conf/extra/httpd-vhosts.conf
第二步:在虚拟主机配置文件中创建虚拟主机
<VirtualHost *:80>
    #设置虚拟域名
    ServerName www.baidu.com
    #设置网站目录
    DocumentRoot "D:/baidu"
    #错误日志路径
    ErrorLog "D:logs/error.log"
    #成功日志路径
    CustomLog "D:logs/access.log"
    <Directory "d:/oa">
            #对于指定目录启用特性
            Options Indexes FollowSymLinks
            #允许所有的访问
            allow from all
            #配置默认首页  
            DirectoryIndex index.php index.html
            #重写模式权限,允许使用.htaccess文件
            #AllowOverride All
            #访问目录有权限
            #Require all granted
    </Directory>
</VirtualHost>
第三步: 重启apche,然后修改本地hosts文件

路径一般在C:\Windows\System32\drivers\etc
添加一条

127.0.0.1 www.baidu.com
上一篇 下一篇

猜你喜欢

热点阅读