skip to Main Content

I changed home directory of Apache “/var/www/html” into “/gwanwoonam/web”
After that, web server returns 403 Error – Forbidden
You don’t have permission to access /info.php on this server.
How Can I fixed that

I googled, and found Solution on permission and SELinux.
I turned off SELinux, So It is disabled.

[gwanwoonam@localhost web]$ getenforce
Disabled

Secondly I tried to edit conf file
sudo vim /etc/httpd/conf/httpd.conf

<Directory />
    AllowOverride none
    #Require all denied
    Require all granted
    Allow from all
</Directory>
...
DocumentRoot "/home/gwanwoonam/web"
...
<Directory "/home/gwanwoonam/web">
    AllowOverride None
    # Allow open access:
    Require all granted
    Allow from all
</Directory>
...
<Directory "/home/gwanwoonam/web">
    #
    # 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 Indexes FollowSymLinks

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

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

And, I put the permission 777 at web directory, sub folder and files of it.

drwxrwxrwx. 2 gwanwoonam gwanwoonam   40 Jul 21 12:19 web
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
-rwxrwxrwx. 1 gwanwoonam gwanwoonam  66 Jul 21 12:19 info.php

However, I cannot solve this problem..
How Can I find solution?


LOGS

[Sun Jul 21 14:04:57.852935 2019] [core:error] [pid 1918] (13)Permission denied: [client ::1:51512] AH00035: access to /favicon.ico denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path, referer: localhost 
[Sun Jul 21 14:05:00.422975 2019] [core:error] [pid 1923] (13)Permission denied: [client 127.0.0.1:42228] AH00035: access to / denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path

2

Answers


  1. In your question you showed this:

    drwxrwxrwx. 2 gwanwoonam gwanwoonam   40 Jul 21 12:19 web
    -rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
    -rwxrwxrwx. 1 gwanwoonam gwanwoonam  66 Jul 21 12:19 info.php
    

    Note that index.html and info.php are not under the web directory. Therefore Apache cannot find them since you told it DocumentRoot "/home/gwanwoonam/web".

    Move your files into /home/gwanwoonam/web, then Apache will see them.


    Then, to ensure you do not have a permissions issue, at the filesystem level, run this:

    chmod 755 /home/gwanwoonam/web
    find /home/gwanwoonam/web -type d -exec chmod 755 {} ;
    find /home/gwanwoonam/web -type f -exec chmod 644 {} ;
    

    This will put permissions
    drwxr-xr-x on all directories (including /home/gwanwoonam/web)
    and
    -rw-r--r-- on files.

    This way your Apache should be able to read all files under web, and return them back to you.

    Login or Signup to reply.
  2. Add the line below to your existing code:

    restorecon -r /home/gwanwoonam/web
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search