简体   繁体   English

Apache 虚拟主机,禁止访问。 使用 XAMPP OS X

[英]Apache Virtual Host, access forbidden. Using XAMPP OS X

I go to "mytest.dev" in the browser, and I get the following error:我在浏览器中转到“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

In my /Applications/XAMPP/etc/httpd.conf file I have the following line UN-commented and my directive thing looks like this:在我的 /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>

My /Applications/XAMPP/etc/extra/httpd-vhosts.conf my virtual host looks like this:我的 /Applications/XAMPP/etc/extra/httpd-vhosts.conf 我的虚拟主机如下所示:

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

My /etc/hosts file has this in it:我的 /etc/hosts 文件中有这个:

127.0.0.1       mytest.dev

However, the above line is in the root /etc NOT in the /Applications/XAMPP/etc.但是,上面的行位于根目录 /etc 中,而不是 /Applications/XAMPP/etc 中。 There is no hosts file inside my /Xampp/etc directory.我的 /Xampp/etc 目录中没有主机文件。

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:最后,因为我在指令中的 DocumentRoot 是这样的:“/Applications/XAMPP/xamppfiles/htdocs/myTest”我有一个 index.php 文件,里面有一个 hello world 脚本,在 myTest 目录中:

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

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我查看了 access_log、error_log 和 php_error_log,但找不到任何类似于我对 mytest.dev 的请求的内容

I also changed permissions for htdocs with this command:我还使用以下命令更改了 htdocs 的权限:

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

all directories from root must be executable for you or the web server to be able to traverse them before they can be read.根目录下的所有目录对于您或 Web 服务器都必须是可执行的,以便能够在读取它们之前遍历它们。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM