Apache虚拟主机,禁止访问.使用XAMPP OS X [英] Apache Virtual Host, access forbidden. Using XAMPP OS X

查看:154
本文介绍了Apache虚拟主机,禁止访问.使用XAMPP OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览器中转到"mytest.dev",出现以下错误:

I go to "mytest.dev" in the browser, and I get the following error:

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文件中,有以下行未注释,并且我的指令内容如下:

In my /Applications/XAMPP/etc/httpd.conf file I have the following line UN-commented and my directive thing looks like this:

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我的虚拟主机看起来像这样:

My /Applications/XAMPP/etc/extra/httpd-vhosts.conf my virtual host looks like this:

<VirtualHost *:80>
       DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/myTest"
       ServerName mytest.dev
</VirtualHost>

我的/etc/hosts文件中包含以下内容:

My /etc/hosts file has this in it:

127.0.0.1       mytest.dev

但是,以上行位于/etcs/XAMPP/etc中的根目录/etc中.我的/Xampp/etc目录中没有主机文件.

However, the above line is in the root /etc NOT in the /Applications/XAMPP/etc. There is no hosts file inside my /Xampp/etc directory.

最后,因为指令中的DocumentRoot是这样的:"/Applications/XAMPP/xamppfiles/htdocs/myTest"我在myTest目录中有一个带有hello world脚本的index.php文件:

Finally, because my DocumentRoot in the directive is this: "/Applications/XAMPP/xamppfiles/htdocs/myTest" I have an index.php file that has a hello world script in it, inside the myTest directory:

...html stuff...
<?php echo '<p>Hello World</p>'; ?>
... html stuff...

我在错误日志中没有发现与我的问题密切相关的任何信息.我查看了access_log,error_log和php_error_log,找不到与我对mytest.dev的请求类似的内容

I'm not getting anything even closely related to my problem in the error logs. I've looked in access_log, error_log, and php_error_log and can't find anything resembling my request to mytest.dev

我还使用以下命令更改了htdocs的权限:

I also changed permissions for htdocs with this command:

sudo chmod 644 /Applications/XAMPP/xamppfiles/htdocs/

推荐答案

根目录中的所有目录对于您或Web服务器必须是可执行的,以便能够遍历它们,然后才能对其进行读取.以下命令应设置正确的权限:

all directories from root must be executable for you or the web server to be able to traverse them before they can be read. the following commands should set the correct permissions:

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 /

然后确保您的网络文件可读且可执行

then to make sure your web files are readable and executable

sudo chmod -R +Xr /Applications/XAMPP/xamppfiles/htdocs/myTest

这篇关于Apache虚拟主机,禁止访问.使用XAMPP OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆