skip to Main Content

I have laravel instaled CentOS 7 server. PHP, MariaDB and HTTPD are installed and works. All services are up and works. Browse the document root shows

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

this is the document root of my server

DocumentRoot "/var/www/html/api/public"

Document root configurations

<Directory "/var/www/html">
    #
    # 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
</Directory>

This is welcome.conf file ( /etc/httpd/conf.d/welcome.conf)

# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL.  To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /.noindex.html
</LocationMatch>

<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>

Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png

What can I do for this issue?

2

Answers


  1. Chosen as BEST ANSWER

    Below server configurations are fixed the issue with me.

    Grant Folder Permission and Set ownership

    chown -R apache:apache /var/www/html/laravel
    chmod -R 755 /var/www/html/laravel/storage
    

    Restore Security

    restorecon -R /var/www
    

    Disable SELinux

    setenforce 0
    

  2. Create and put this .htaccess file in your app folder.

    
    
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^public
        RewriteRule ^(.*)$ public/$1 [L]
    
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search