Apache Virtual Host, access forbidden. Using XAMPP OS X

淺唱寂寞╮ 提交于 2020-03-06 03:36:15

问题


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

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>

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>

My /etc/hosts file has this in it:

127.0.0.1       mytest.dev

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.

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...

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

I also changed permissions for htdocs with this command:

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

回答1:


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


来源:https://stackoverflow.com/questions/36606234/apache-virtual-host-access-forbidden-using-xampp-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!