longpan 发表于 2018-11-24 12:40:08

apache 多ip虚拟主机

  apache配置多ip虚拟有2种方法
  第一种-通过设置不同的端口来配置
  1创建一个目录,作为接口
  2设置apche虚拟主机(不用配置虚拟目录映射)
  httpd.conf开启虚拟主机配置,接着到httpd-vhosts.conf里面设置


[*]    //这里改变端口
[*]   DocumentRoot "D:/myblog"//这个就是第一步创建的接口
[*]   DirectoryIndex index.html index.htm index.php
[*]   
[*]   Options FollowSymLinks
[*]   Allowoverride None
[*]   order Allow,deny
[*]   Allow from all
[*]   
[*]
[*]
[*]
[*]   DocumentRoot "D:/baidu"
[*]   DirectoryIndex index.html index.htm index.php
[*]   
[*]   Options FollowSymLinks
[*]   Allowoverride None
[*]   order Allow,deny
[*]   Allow from all
[*]   
[*]

  3-到httpd.conf文件里面修改监听端口


[*]Listen 80
[*]Listen 81

  4-到host文件里面修改映射.登录网站时候记得加端口号。
  第二种方法:通过ServerName配置
  1创建一个目录,作为接口
  2设置apche虚拟主机(不用配置虚拟目录映射)
  httpd.conf开启虚拟主机配置,接着到httpd-vhosts.conf里面设置


[*]//记得ip必须为*否则不行的
[*]   DocumentRoot "D:/myblog"//目录
[*]   ServerName www.lengai.com//域名
[*]   DirectoryIndex index.html index.htm index.php
[*]   
[*]   Options FollowSymLinks
[*]   Allowoverride None
[*]   order Allow,deny
[*]   Allow from all
[*]   
[*]
[*]
[*]
[*]   DocumentRoot "D:/baidu"
[*]    ServerName www.beijing.com
[*]   DirectoryIndex index.html index.htm index.php
[*]   
[*]   Options FollowSymLinks
[*]   Allowoverride None
[*]   order Allow,deny
[*]   Allow from all
[*]   
[*]

  3重启apache。就可以了,当然要配置hosts



页: [1]
查看完整版本: apache 多ip虚拟主机