2016-12-30 36 views
3

clg.localhost/で、私はエラーになっています:Apacheは - あなたはアクセス権限がありません/このサーバー

You don't have permission to access/on this server.

をしかし、this以下、私がアクセスを許可するように私のApache httpd.confsites.confを設定しましたAllowOverride allおよびRequire all grantedである。ほかに何が足りないのですか?

バージョン:

$ /usr/sbin/httpd -v 
Server version: Apache/2.4.23 (Unix) 
Server built: Aug 8 2016 18:10:45 

のApacheのhttpd.conf:

DocumentRoot "/Users/danniu/Sites" 
<Directory "/Users/danniu/Sites"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important. Please see 
    # http://httpd.apache.org/docs/2.4/mod/core.html#options 
    # for more information. 
    # 
    Options FollowSymLinks Multiviews 
    MultiviewsMatch Any 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # AllowOverride FileInfo AuthConfig Limit 
    # 
    AllowOverride all 

    # 
    # Controls who can get stuff from this server. 
    # 
    Require all granted 
</Directory> 

... 

# 
# Deny access to the entirety of your server's filesystem. You must 
# explicitly permit access to web content directories in other 
# <Directory> blocks below. 
# 
<Directory /> 
    AllowOverride all 
    Require all granted  
</Directory> 

Apacheのsites.conf:

# Workaround for missing Authorization header under CGI/FastCGI Apache: 
<IfModule setenvif_module> 
    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 
</IfModule> 

# Serve ~/Sites at http://localhost 
ServerName localhost 

<VirtualHost *:80> 
    ServerName clg.localhost 
    DocumentRoot /Users/danniu/Sites/CLG/CLG-dev 
</VirtualHost> 

私はhttpd.confが正しくので、ピックアップされていなかったかもしれないと思いました私は同じ問題で、仮想ホストに直接ルートを指定しました。あなたは、インデックスファイルはindex.htmlなどのDirectoryIndex、と指されていない、とあなたはインデックスが有効になっていないので、もし

<VirtualHost *:80> 
    ServerName clg.localhost 
    DocumentRoot /Users/danniu/Sites/CLG/CLG-dev 
    # Set access permission 
    <Directory "/Users/danniu/Sites/CLG/CLG-dev"> 
    Require all granted 
    </Directory> 
</VirtualHost> 
+0

'/ Users/danniu/Sites/CLG/CLG-dev'のルートに' index.html'、 'default.htm'のようなデフォルトのドキュメントタイプに合ったファイルがあるかどうかチェックし、その設定をapache configから削除しないでください。 –

+0

@KraangPrimeそれは 'index.php'です。しかし、まだ 'index'をピックアップするべきでしょうか?そうでなければ、どうすればphpファイルとして指定できますか?そして、Apache設定のどの設定について話していますか? – Growler

+0

Apache設定の設定は 'DirectoryIndex'です。例: 'DirectoryIndex index.php default.php index.htm default.htm index.html default.html index.phps'。 phpファイルを実行する場合、手元にある単純なHTMLファイルを表示できることを確認します。 PHPがインストールされており、モジュールがリンクされている/適切に読み込まれていると仮定します。 –

答えて

2

/あなたがいないそうであるように、Apacheができ、ディレクトリですあなたのドキュメントルートの内容を表示しないでください。

はオプションに、あなたはOptions FollowSymLinks Multiviews

ソリューションを持っていますインデックスが好き追加「ディレクトリ一覧」(これは以前にロードされているmod_autoindexのに依存します)のために、次のとおりです。あなたは、デフォルトのファイルが必要な場合

Options FollowSymLinks Multiviews Indexes 

index.htmlのようにロードされている場合、DirectoryIndexはデフォルトでindex.htmlを探しますので、追加してください。または、別の場所でその動作を上書きするものがある場合は、

DirectoryIndex index.html 
関連する問題