background image

PHP

配置 apache 配置虚拟主机的方法

本篇文章是对 apache 配置虚拟主机的方法进行了详细的分析介绍,需要的朋友参考

1.apache 配置文件中打开 vhost 的配置

LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf

2.extra 目录中的 httpd-vhosts.conf

里面进行配置,有三个:第一个 DocumentRoot,项目的绝对目录,后面以/结尾;第二个
是 ServerPath,与 DocumentRoot 一致;第三个是 ServerName,自己在浏览器中输入的域
名。如:test.123.cn

3.在 hosts 文件中位域名指向。如:127.0.0.1 test.123.cn