linuxx 发表于 2018-11-22 12:34:51

Apache应用中多个站点的解决方法

  在整合Apache应用中,有两个站点,server104.example.com和www104.example.com发现第二站点被第一个站点给覆盖,又不能改变访问的80端口号,解决方法设置总结如下:
  主要设置httpd.conf
  1、DirectoryIndex的设置
  如果多个虚拟站点中包含多种文件格式和文件名的首页文件,必须在这里全部出现
  2、多个站点的定义如下
  #NameVirtualHost *:80
  # VirtualHost example:
  # Almost any Apache directive may go into aVirtualHost container.
  # The first VirtualHost section is used forrequests without a known
  # server name.
  NameVirtualHost 192.168.0.104:80
  
  ServerAdmin root@example.com
  DocumentRoot/var/www/html/server104
  ServerNameserver104.example.com
  DirectoryIndex   example.html
  ErrorLoglogs/ronglian.com-error_log
  CustomLoglogs/ronglian.com-access_log common
  
  
  ServerAdmin root@example.com
  DocumentRoot/var/www/html/www104
  ServerName   www104.example.com
  DirectoryIndex   virtual.html
  ErrorLoglogs/chinaface.net-error_log
  CustomLoglogs/chinaface.net-access_log common
  
  ①在这里,NameVirtualHost的字段不能省略,否则起apache时报错:VirtualHost 192.168.0.104.80 overlaps with VirtualHost192.168.0.104:80, the first has precedence, perhaps you need a NameVirtualHostdirective——虽然apache能起,同错误描述一样,第二个站点的定义被第一个站点的定义所覆盖,即访问第二个站点指向的其实是第一个。
  ②NameVirtualHost字段的端口号不能忽略,否则起apache时报错:VirtualHost 192.168.0.104:80 -- mixing * ports and non-* ports witha NameVirtualHost address is not supported, proceeding with undefined results
   VirtualHost 192.16.0.104.*:80 -- mixing * ports and non-* ports with aNameVirtualHost address is not supported, proceeding with undefined results——apache不能起作用.
  

  




页: [1]
查看完整版本: Apache应用中多个站点的解决方法