OSX Apache で動的仮想ホストが 403 禁止を返す

OSX Apache で動的仮想ホストが 403 禁止を返す

私はフォローしましたこのガイドfoo.devそして、 Web フォルダーへの直接アクセスを許可することで、OSX 上で動的 vhosts を作成しようとしています/foo。私の違いは、ガイドにあるように Mac HD ではなく Web フォルダーを使用していることです~/Sites。dnsmasq を使用していますが、これはインストールされて正常に動作していると思います。

私の ~/Sites フォルダには次のものがあります:

home
sites
|-foo
|-bar

私の httpd-vhosts.conf は次のようになります:

<Virtualhost *:80>
DocumentRoot "/Users/harryg/Sites/home"
ServerName home.dev
UseCanonicalName Off
ErrorLog "logs/home/error.log"
<Directory "/Users/harryg/Sites/home">
    #Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Allow from all
</Directory>
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/harryg/Sites/sites/%1"
<Directory "/Users/harryg/Sites/sites/%1">
    Options FollowSymLinks
    #Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Allow from all
</Directory>
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>

最初の vhost は正常に動作し、その vhost のルートにあるhome.devサンプル ファイルに移動します。index.php

2 番目の vhost は、.dev のサブドメインにフォルダーが存在するかどうかに関係なく、anything.dev に対して 403 Forbidden エラーを返すだけです。

何か案は?

編集:

最新のログエントリ

Apache エラー ログ:

[Wed Dec 18 00:45:37 2013] [error] [client 127.0.0.1] File does not exist: /Users/harryg/Sites/home/favicon.ico
[Wed Dec 18 00:45:45 2013] [error] [client 127.0.0.1] client denied by server configuration: /Users/harryg/Sites/sites/test/, referer: http://home.dev/
[Wed Dec 18 00:45:45 2013] [error] [client 127.0.0.1] client denied by server 

サーバーは現在動作します (構成ファイルのエラー ログ ディレクトリに問題がありました)。ただし、まだ動的 vhosts にアクセスできません。

答え1

2番目のサイトのコンテンツは何ですか?

考えられる理由は 2 つあります。

  1. ディレクトリに索引ドキュメント (index.php、index.html、default.html など) およびディレクトリの一覧表示が許可されていない場合、Apache は 403 エラー ページを表示します。

  2. sites.dev で ExecCGI が有効になっていないことに気付きました。有効にしていただけますか?

更新しました:パス内のパーセント記号 ( /Users/harryg/Sites/sites/%1) は mod_vhost_alias 用ですが、Apache の<Directory>ルール用ではありません。これを変更してください:

<Directory "/Users/harryg/Sites/sites/%1">

これに対して:

<Directory "/Users/harryg/Sites/sites">

それは機能しますか?

答え2

ちょうど同じ問題に遭遇しましたが、これはApacheのデフォルト設定であることがわかりました。httpd.confにはこれがあります

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

「Deny from all」行を削除し、Apache を再起動します。

答え3

403 エラーはアクセスが拒否されたことを示します。サイト ディレクトリまでのツリー ディレクトリの権限を確認する必要があります。

Apache を実行しているユーザーに、ディレクトリに対する読み取り権限と実行権限、およびファイルに対する読み取り権限があることを確認します。

関連情報