Apache2 VirtualHost 403 error
来源:互联网 发布:欧美护肤品推荐知乎 编辑:程序博客网 时间:2024/05/17 12:53
Apache2 配置VirtualHost的时候出现403权限问题。因为主要想把开发机器配置成多个VirtualHos,所以才发现虽然很简单,但是还是要翻手册的,于是记录在案。
1、修改hosts文件
windows下(C盘安装系统)
C:\Windows\System32\drivers\etc加入如下内容:代表浏览器直接输入 http://outman/ 来访问你配置的项目目录
127.0.0.1 outman
2、配置VirtualHost,在apache的配置文件目录下,httpd.conf文件中加入下面的代码(为了整齐可以单独配置文件后包含,也可以写在注释的VirtualHost节点处,利于修改)
NameVirtualHost *:80<VirtualHost *:80>DocumentRoot "F:/www/php"ServerName outman<directory "F:/www/php">Allow from all</directory></VirtualHost># 注意下面这一段很重要,处理403的<directory "F:/www/php">Allow from all</directory>
注意:配置以后,其他的localhost也会被转入到这个地址,注意配置hosts,和其他项目的地址,所以这里注意其他的最好也配置为虚拟机,这样相对比较好管理。
以下为转载内容。
error 403 with virtual hosts
Working with virtual hosts under Apache2 is pretty easy, but I had some trouble getting things started due to some unclear docs and lack of examples. My biggest problem was the "HTTP 403 / client denied by server configuration error".
There are two causes to 403 errors with virtual hosts.
First, every single parent path to the virtual document root must be Readable, Writable, and Executable by the web server httpd user. The access_log will show a 403 code, but the following message is returned to the browser with no "403" string printed:
Forbidden You don't have permission to access /index.html on this server.
I got nailed a couple of times because one of the parent directories in the virtual document root was not executable by 'www' (the user my web server runs as). The error log file messages offer no hints when this happens. It makes it seem like a configuration problem, so you can waste a lot of time look for the problem in httpd.conf.
The second cause is actually a configuration problem -- the problem is forgetting to allow access in the httpd.conf. In this case the access_log will show a 403 error and Aapche2 will also sometimes send a "403" in the error string to the browser:
HTTP 403 / client denied by server configuration error
It may also send the Forbidden message with no "403" string. I don't know what this difference means.
Forbidden You don't have permission to access /index.html on this server.
A tail of the error_log gives a message like this for each access attempt:
[Tue Jul 25 17:58:17 2006] [error] [client 192.168.1.1] client denied by server configuration: /var/www/vhosts/palermo/
The problem is that the extra/httpd-vhosts.conf is missing the directive to allow access to the directory.
Allow access by adding a <directory> section inside the <vhost> section.
<directory /vhost_document_root>allow from all<directory>
The following should give a better idea of how this should work:
<VirtualHost *> ServerName palermo.example.com ServerAlias palermo.example.com DocumentRoot /var/www/vhosts/palermo <directory /var/www/vhosts/palermo> allow from all </directory></VirtualHost>
It is strange that neither the sample httpd-vhosts.conf file that comes with Apache2 nor the Apache2 documentation on VirtualHost gives a example that could work.
- Apache2 VirtualHost 403 error
- Apache2 VirtualHost的配置方法
- centos apache2.4 设置 VirtualHost
- WampServer-Apache2中VirtualHost 403 无权限访问的问题及解决
- apache virtualhost 403 forbidden
- 关于Apache2 VirtualHost二级域名只生效一个的问题
- [error] VirtualHost *:80 -- mixing * ports and non-* ports 错误
- Apache2.4 虚拟主机(VirtualHost)的配置方法,用来解决client denied by server configuration
- python apache2 Internal Server Error
- Xampp上设置VirtualHost出现403的问题(windows上)
- Apache VirtualHost
- APACHE VirtualHost
- virtualhost apache
- VirtualHost Examples
- 关于Apache: [warn] _default_ VirtualHost overlap on port 80, the first has precedence Error and Solution的解决方案
- apache2
- apache2
- Apache2
- Oracle Hints详解
- 在ubuntu11.10下安装Audacious3.1.1
- NYOJ 14 会场安排问题
- IAR STM8工程中断的使用(转)
- LINUX下编译安装PROTOBUF
- Apache2 VirtualHost 403 error
- NULL
- SQL语句分类
- 设计模式学习笔记一 简单工厂策略模式实现销售策略的变更(一)
- 杭电1003
- dom4j操作xml
- PHP Smarty 3中实现多语言模板及标签静态化的方法
- 运动会报名(2)
- Python - 获取校内(人人网)的所有好友照片存储到本地