Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2780917
  • 博文数量: 77
  • 博客积分: 10204
  • 博客等级: 上将
  • 技术积分: 5035
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-05 22:13
文章分类
文章存档

2013年(1)

2010年(1)

2009年(17)

2008年(58)

我的朋友

分类: BSD

2008-10-26 20:41:39

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 section inside the section.


allow from all

The following should give a better idea of how this should work:


    ServerName palermo.example.com
    ServerAlias palermo.example.com
    DocumentRoot /var/www/vhosts/palermo
    
    allow from all
    

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.

Retrieved from ""
阅读(2375) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~