[英]Apache Virtual Host, access forbidden. Using XAMPP OS X
我在瀏覽器中轉到“mytest.dev”,出現以下錯誤:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
mytest.dev
Apache/2.4.18 (Unix) OpenSSL/1.0.2g PHP/5.6.19 mod_perl/2.0.8-dev Perl/v5.16.3
在我的 /Applications/XAMPP/etc/httpd.conf 文件中,我對以下行進行了未注釋,並且我的指令如下所示:
Include etc/extra/httpd-vhosts.conf
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
我的 /Applications/XAMPP/etc/extra/httpd-vhosts.conf 我的虛擬主機如下所示:
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/myTest"
ServerName mytest.dev
</VirtualHost>
我的 /etc/hosts 文件中有這個:
127.0.0.1 mytest.dev
但是,上面的行位於根目錄 /etc 中,而不是 /Applications/XAMPP/etc 中。 我的 /Xampp/etc 目錄中沒有主機文件。
最后,因為我在指令中的 DocumentRoot 是這樣的:“/Applications/XAMPP/xamppfiles/htdocs/myTest”我有一個 index.php 文件,里面有一個 hello world 腳本,在 myTest 目錄中:
...html stuff...
<?php echo '<p>Hello World</p>'; ?>
... html stuff...
我在錯誤日志中沒有得到任何與我的問題密切相關的信息。 我查看了 access_log、error_log 和 php_error_log,但找不到任何類似於我對 mytest.dev 的請求的內容
我還使用以下命令更改了 htdocs 的權限:
sudo chmod 644 /Applications/XAMPP/xamppfiles/htdocs/
根目錄下的所有目錄對於您或 Web 服務器都必須是可執行的,以便能夠在讀取它們之前遍歷它們。 以下命令應設置正確的權限:
sudo chmod +X /Applications/XAMPP/xamppfiles/htdocs
sudo chmod +X /Applications/XAMPP/xamppfiles
sudo chmod +X /Applications/XAMPP
sudo chmod +X /Applications
sudo chmod +X /
然后確保您的網絡文件可讀和可執行
sudo chmod -R +Xr /Applications/XAMPP/xamppfiles/htdocs/myTest
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.