如何在Apache中开启虚拟主机,apache开启虚拟主机


首先在apache的安装目录下的conf\extra\httpd-vhosts.conf中添加如下

<VirtualHost *:80>  //虚拟主机端口号
   ServerAdmin 1778023831@qq.com  //服务器管理员邮箱
    DocumentRoot "E:/PHPWorkj/think/public/index.php"  //虚拟主机需要映射到的项目地址
    ServerName zxl.com  
    ServerAlias www.zxl.com   //虚拟主机访问域名
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost>
接着在conf/httpd.conf中加入 <Directory />
   Options Indexes FollowSymLinks 
     AllowOverride None  
     Allow from all 
</Directory> 在把 LoadModule access_compat_module modules/mod_access_compat.so #基于主机的组授权(名称或IP地址) httpd 2.x兼容的模块,
LoadModule proxy_module modules/mod_proxy.so #apache的代理模块
LoadModule proxy_http_module modules/mod_proxy_http.so #代理http和https请求
LoadModule vhost_alias_module modules/mod_vhost_alias.so #虚拟主机动态配置
LoadModule authz_host_module modules/mod_authz_host.so #基于主机的组授权
Include conf/extra/httpd-vhosts.conf#启用虚拟主机配置 以上模块前面的#去除 找到C:\Windows\System32\drivers\etc\hosts 在里面把localhost换成刚才的域名即可


相关内容

    暂无相关文章