xampp 虚拟主机配置

测试环境 xampp3.2.1 + win7

一、基于端口的虚拟主机

(1)Apache配置文件 httpd.conf 改动:

A、 搜索“Listen”。增加两个新端口

  Listen 8000

  Listen 8001

B、搜索“vhosts” 。确保“Include conf/extra/httpd-vhosts.conf” 前无注释符号“#”

(2)改动 vhosts.conf文件

增加配置项


    ##ServerAdmin [email protected]
    DocumentRoot "D:/Program Files (x86)/xampp/htdocs/keya/4_upload"
    ##ServerName keya
    ErrorLog "logs/keya-error.log"
    CustomLog "logs/keya-access.log" common


  Order allow,deny
  Allow from all


    ##ServerAdmin [email protected]
    DocumentRoot "D:/Program Files (x86)/xampp/htdocs/nw"
    ##ServerName ylk
    ErrorLog "logs/nw-error.log"
    CustomLog "logs/nw-access.log" common


  Order allow,deny
  Allow from all

(3)访问

chrome 浏览器访问 localhost:8000或者localhost:8001

二、基于域名的虚拟主机
(1)配置C:\Windows\System32\drivers\etc\hosts文件

     加两行

           127.0.0.1    keya

           127.0.0.1    ylK

(2) 修改apache的配置文件 httpd.conf

          A、监听端口                 Listen 80

          B、包含虚拟主机配置文件     “Include conf/extra/httpd-vhosts.conf”   确保这句话前无注释符号

(3)修改httpd-vhosts.conf


    ##ServerAdmin [email protected]
    DocumentRoot "D:/Program Files (x86)/xampp/htdocs/keya/4_upload"
    ServerName keya
    ErrorLog "logs/keya-error.log"
    CustomLog "logs/keya-access.log" common


  Order allow,deny
  Allow from all


    ##ServerAdmin [email protected]
    DocumentRoot "D:/Program Files (x86)/xampp/htdocs/nw"
    ServerName ylk
    ErrorLog "logs/nw-error.log"
    CustomLog "logs/nw-access.log" common


  Order allow,deny
  Allow from all

        

             



 

你可能感兴趣的:(apache)