2.4.12之虚拟主机配置问题与觖决办法

Apache-2.4.12基于域名访问的多虚拟主机配置

原始配置:
<VirtualHost *:80>
    ServerAdmin kk@linuxidc.net
    DocumentRoot "/data/cms"
    ServerName
    ServerAlias linuxidc.net
    ErrorLog "logs/www.linuxidc.net-error_log"
    CustomLog "logs/www.linuxidc.net-access_log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin kk@linuxidc.net
    DocumentRoot "/data/bbs"
    ServerName bbs.linuxidc.net
    ErrorLog "logs/bbs.linuxidc.net-error_log"
    CustomLog "logs/bbs.linuxidc.net-access_log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin kk@linuxidc.net
    DocumentRoot "/data/blog"
    ServerName blog.linuxidc.net
    ErrorLog "logs/blog.linuxidc.net-error_log"
    CustomLog "logs/blog.linuxidc.net-access_log" common
</VirtualHost>
    以上的基于域名访问的多虚拟主机配置大家能看出错在哪吗?乍一看没有问题,可是在apache-2.4.12下这样配置完,访问出现403错误,无权限访问。根据提示查看了目录以及文件的权限问题,没有问题;查看程序错误日志和系统日志也没有明显的错误;这时冷静下来好好想了想,目录及文件权限没有问题,那剩下就是站点目录访问权限了,于是在虚拟主机配置文件里面的虚拟主机配置前加入这么一段:

<Directory "虚拟主机站点目录">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

再些修改虚拟主机配置文件如下:

<Directory "/data">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>
<VirtualHost *:80>
    ServerAdmin kk@linuxidc.com
    DocumentRoot "/data/cms"
    ServerName
    ServerAlias linuxidc.net
    ErrorLog "logs/www.linuxidc.net-error_log"
    CustomLog "logs/www.linuxidc.net-access_log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin kk@linuxidc.com
    DocumentRoot "/data/bbs"
    ServerName bbs.linuxidc.net
    ErrorLog "logs/bbs.linuxidc.net-error_log"
    CustomLog "logs/bbs.linuxidc.net-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kk@linuxidc.com
    DocumentRoot "/data/blog"
    ServerName blog.linuxidc.net
    ErrorLog "logs/blog.linuxidc.net-error_log"
    CustomLog "logs/blog.linuxidc.net-access_log" common
</VirtualHost>

经过以上的修改后,重启Apache服务,现在可以正常访问,呵呵,大功能告成!

-------------------------------------我是分割线 -------------------------------------

Ubuntu下Apache的Rewrite如何启用 

Ubuntu 14.04中Apache 2.2升级到2.4后的几个要点

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置

CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)

RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind

LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP

--------------------------------------分割线 --------------------------------------

Apache 的详细介绍请点这里
Apache 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9f2dda189e29839c5a372107dcd50fb2.html