PHP 使用WampServer环境,如何配置虚拟主机域名

很多人不会配置虚拟主机,我这里简单交一下大家,分三步:

  1、在 C:WindowsSystem32driversetc 文件夹中的文件 Hosts 文件修改代码为:

  127.0.0.1 localhost

  127.0.0.1 www.zhixing123.cn

  2、在apache的配置文件中,也就是httpd.conf中 ,把虚拟主机打开

  (范例路径:D:wampinapacheapache2.2.8conf)

  # Virtual hosts

  Include conf/extra/httpd-vhosts.conf

  3、extra/httpd-vhosts.conf 在这个文件中修改代码为:

  (范例路径:D:wampinapacheapache2.2.8confextra)

   ServerAdmin webmaster@dummy-host.localhost

   DocumentRoot "d:/wamp/www"

   ServerName localhost

   ServerAlias www.dummy-host.localhost

   ErrorLog "logs/dummy-host.localhost-error.log"

   CustomLog "logs/dummy-host.localhost-access.log" common

   ServerAdmin webmaster@dummy-host2.localhost

   DocumentRoot "d:/wamp/www/www_zhixing123_cn"

   ServerName www.zhixing123.cn

   ErrorLog "logs/dummy-host2.localhost-error.log"

   CustomLog "logs/dummy-host2.localhost-access.log" common

  完成以上三步,则本地可以用虚拟域名访问本机了。

  接下来用本机访问一下你设置的域名试试。

  对新手做东西应该还是有所帮助的吧。      

注:转载自    http://www.zhixing123.cn/php/32114.html(原创)

原文地址:https://www.cnblogs.com/anyefrozen/p/4562689.html