简体   繁体   中英

Apache Virtual Host, access forbidden. Using XAMPP OS X

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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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