Apache(Xampp)で「client denied by server configuration:」エラーの解決方法

Windowsデスクトップ上にRAMP開発環境を作るため、XAMPPをインストール。

を編集して、バーチャルホストのサンプル設定をコピーして表示させようとしたところ…

サンプル設定

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host.example.com
    ##DocumentRoot "C:/Users/Public/xampp/htdocs/dummy-host.example.com"
    ##ServerName dummy-host.example.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

上手くいかない記述

<VirtualHost *:80>
    DocumentRoot "C:/dacelo/web/public_html"
    ServerName dacelo.loc
    ServerAlias www.dacelo.loc
    ErrorLog "logs/dacelo.loc-error.log"
    CustomLog "logs/dacelo.loc-access.log" common
</VirtualHost>

あれ?表示されない。エラーログ(上記例の場合の場所は logs/dacelo.loc-access.log)を見てみると、こんなエラーが。

[Wed Feb 19 15:24:18.107404 2014] [authz_core:error] [pid 3320:tid 1636] [client 127.0.0.1:60164] AH01630: client denied by server configuration: C:/dacelo/web/public_html/

あ、そうそう。Windows上でApacheを動かす場合、Directoryでアクセス権を許可してあげないといけないんでした。

<directory "C:/dacelo/web/public_html">
  Order allow,deny
  Allow from all
</directory>

を追加します。これでOK。

のはずが、やっぱりだめ。おかしいなと思って調べてみると、directory ディレクティブの書き方がapache2.4から変わっていました。

apache2.4以降の記述

<directory "C:/dacelo/web/public_html">
  Require all granted
</directory>

これで解決です。

ちゃんと表示される記述

<VirtualHost *:80>
    DocumentRoot "C:/dacelo/web/public_html"
    ServerName dacelo.loc
    ServerAlias www.dacelo.loc
    ErrorLog "logs/dacelo.loc-error.log"
    CustomLog "logs/dacelo.loc-access.log" common
       <directory "C:/dacelo/web/public_html">
           Require all granted
       </directory>
</VirtualHost>

広告

About: dacelo


2 thoughts on “Apache(Xampp)で「client denied by server configuration:」エラーの解決方法”

Leave a Reply

Your email address will not be published. Required fields are marked *