4

At clg.localhost/ I'm getting error:

You don't have permission to access / on this server.

But, following this, I've set up my Apache httpd.conf and sites.conf to allow access with AllowOverride all and Require all granted. What else am I missing?

Versions:

$ /usr/sbin/httpd -v
Server version: Apache/2.4.23 (Unix)
Server built:   Aug  8 2016 18:10:45

Apache httpd.conf:

DocumentRoot "/Users/danniu/Sites"
<Directory "/Users/danniu/Sites">
    #
    # 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/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

...

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride all
    Require all granted     
</Directory>

Apache sites.conf:

# Workaround for missing Authorization header under CGI/FastCGI Apache:
<IfModule setenvif_module>
  SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>

# Serve ~/Sites at http://localhost
ServerName localhost

<VirtualHost *:80>
   ServerName clg.localhost
   DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
</VirtualHost>

I thought perhaps httpd.conf wasn't properly being picked up, so I specified the root directly in the Virtual Host, with the same issue.

<VirtualHost *:80>
   ServerName clg.localhost
   DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
   # Set access permission
   <Directory "/Users/danniu/Sites/CLG/CLG-dev">
     Require all granted
  </Directory>
</VirtualHost>
Community
  • 1
  • 1
user3871
  • 12,432
  • 33
  • 128
  • 268
  • Check if there is a file that matches the default document type in the root of `/Users/danniu/Sites/CLG/CLG-dev` like, `index.html`, `default.htm` and check that you didn't remove that setting from apache config. – Kraang Prime Dec 30 '16 at 07:01
  • @KraangPrime it's `index.php`. It should still pick up `index` though, right? If not, how can I specify it as a php file? And which setting in apache config are you talking about? – user3871 Dec 30 '16 at 07:05
  • The setting in apache config is `DirectoryIndex` . For example : `DirectoryIndex index.php default.php index.htm default.htm index.html default.html index.phps` . As for running a php file -- check that it can display just plain html files before hand. I assume you have php installed and the module linked / loaded properly. – Kraang Prime Dec 30 '16 at 07:13
  • Check file system permissions, does user running httpd process has read permissions for `/Users/danniu/Sites/CLG/CLG-dev`? – Dusan Bajic Dec 30 '16 at 08:48

1 Answers1

5

/ is a directory, so if you don't have an index file pointed to with DirectoryIndex, such as index.html, and you don't have Indexes enabled, as you don't, Apache can't show contents of your documentroot.

Note you have Options FollowSymLinks Multiviews

The solution, to the Options add Indexes like follows for "directory listing" (this depends on mod_autoindex being loaded previously):

Options FollowSymLinks Multiviews Indexes

If you want a default file loaded, for example index.html, DirectoryIndex by default looks for index.html, so add it, or if something its overriding its behaviour somewhere else do:

DirectoryIndex index.html 
Daniel Ferradal
  • 2,727
  • 1
  • 13
  • 19