server下apache2.4.*虚拟主机配置Forbidden You don't have permission to access / on this server.
2014-08-23 19:44
337 查看
前言:
继前面两节笔记之后,在配置一个虚拟主机时,这中间却遇见了一个问题,这里需要描述做一下笔记,刚刚安装的是Ubuntu server,apt-get下来的apache的版本是2.4.7,之前一直用的是apache2.2的,期间遇见过403错误,只是问题处理的方式方法有些不一样,于是这里就一时没有找到头绪。本文原创博客地址:http://www.cnblogs.com/unofficial官网地址:www.pushself.com)403:没有权限访问
不说废话直接找主题:
首先我们来回顾一下apache2.2的配置<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory>
server默认000-default.conf配置文件,在copy的文件后没有发现directory这一部分,搜也没有搜出想要的答案,在apache官网上发现了这一变化。
In this example, all requests are denied. 2.2 configuration: Order deny,allow Deny from all 2.4 configuration: Require all denied In this example, all requests are allowed. 2.2 configuration: Order allow,deny Allow from all 2.4 configuration: Require all granted In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access. 2.2 configuration: Order Deny,Allow Deny from all Allow from example.org 2.4 configuration: Require host example.org
看到上面的配置文件应该可以看出一部分问题,配置文件的写法有些变化了,需要将配置文件修改为Require all granted。
官网解释:http://httpd.apache.org/docs/2.4/upgrading.html本文原创博客地址:http://www.cnblogs.com/unofficial官网地址:www.pushself.com)
虚拟主机配置步骤:
配置一个ServerName:demo.pushself.com
① 复制一份默认的配置文件
cd /etc/apache2/sites-available sudo cp 000-default.conf demo.conf sudo vim demo.conf ServerName demo.pushself.com #新增一句ServerName ServerAdmin webmaster@localhost DocumentRoot /wwwroot/demo #修改为你的项目路径 <Directory /wwwroot/demo> #新增权限配置不同于2.2 Require all granted </Directory> sudo ln -s /etc/apache2/sites-available/demo.conf /etc/apache2/sites-enabled/demo.conf sudo service apache2 restart
②我是远程连接的server,所以我需要修改一下客户端的hosts文件,添加一句模拟DNS
192.168.25.107 demo.pushself.com #IP是我的server地址
注意:如果上述配置后还是还是会403 Forbidden,原因是没有index文件,为了解决这个问题,我们可以再配置文件添加一句,新增后记得重启apache
<Directory /wwwroot/demo> #新增权限配置不同于2.2 Options FollowSymLinks Indexes Require all granted </Directory>
本文原创博客地址:http://www.cnblogs.com/unofficial官网地址:www.pushself.com)
相关文章推荐
- apache server 配置虚拟主机
- Apache配置虚拟主机的坑 本地wampserver调试环境 局域网访问
- Apache2.4 虚拟主机(VirtualHost)的配置方法,用来解决client denied by server configuration
- Ubuntu Server 14.04 & Apache2.4 虚拟主机、模块重写、隐藏入口文件配置
- Apache Server设置虚拟主机
- linux系统配置Apache虚拟主机实例
- Tomcat、Apache、IIS的配置(无虚拟主机介绍)
- Apache 虚拟主机的配置.
- 在Apache中配置虚拟主机
- linux系统配置Apache虚拟主机实例
- Apache虚拟主机的配置
- Apache下的虚拟主机配置方法
- apache基于IP,port和域名三种虚拟主机配置方法
- LINUX系统apache基于IP,基于port和基于域名的三种虚拟主机的配置方法
- apache2.2.9配置虚拟主机问题
- APACHE虚拟主机配置方法
- Apache同IP不同端口虚拟主机配置。
- 用apache在本机配置多个基于ip的虚拟主机
- 如何配置apache一个ip多域名的虚拟主机?
- Fedora10下配置Apache和虚拟主机