archer05 发表于 2018-11-18 11:40:07

apache2.4.27配置虚拟主机

  1:在httpd.conf中,把这行打开
  Include conf/extra/httpd-vhosts.conf
  2:进到conf/extra/里,修改httpd-vhosts.conf
  

  原文件是这样的

  
  ServerAdmin webmaster@dummy-host.example.com (邮箱)
  DocumentRoot "/web/www1" (发布目录)
  ServerName www.luo.com (域名)
  ServerAlias www.luo2.com (这可配置多域名)
  ErrorLog "logs/dummy-host.example.com-error_log" (日志)
  CustomLog "logs/dummy-host.example.com-access_log" common(日志)
  
  

  
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "/web/www2"
  ServerName www.luo1.com
  ErrorLog "logs/dummy-host2.example.com-error_log"
  CustomLog "logs/dummy-host2.example.com-access_log" common
  
  

  这样配置好后还是打不开,显示无权限
  乍一看没有问题,可是在apache-2.4.37下这样配置完,无权限访问。根据提示查看了目录以及文件的权限问题,没有问题;查看程序错误日志和系统日志也没有明显的错误;这时冷静下来好好想了想,目录及文件权限没有问题,那剩下就是站点目录访问权限了,于是在虚拟主机配置文件里面的虚拟主机配置后加这么一段

    AllowOverride All
    Options Indexes FollowSymLinks Includes ExecCGI
    Order allow,deny
    Allow from all
  

  配置文件如下
  

  
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot "/web/www1"
  ServerName www.luo.com
  ServerAlias www.luo2.com
  ErrorLog "logs/dummy-host.example.com-error_log"
  CustomLog "logs/dummy-host.example.com-access_log" common
  
  
  AllowOverride All
  Options Indexes FollowSymLinks Includes ExecCGI
  Order allow,deny
  Allow from all
  

  
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "/web/www2"
  ServerName www.luo1.com
  ErrorLog "logs/dummy-host2.example.com-error_log"
  CustomLog "logs/dummy-host2.example.com-access_log" common
  

    AllowOverride All
    Options Indexes FollowSymLinks Includes ExecCGI
    Order allow,deny
    Allow from all
  

  经过以上的修改后,重启Apache服务,现在可以正常访问



页: [1]
查看完整版本: apache2.4.27配置虚拟主机