php - Laravel 文档根目录被 HTTP 403 错误禁止
问题描述
我有 laravel 安装了 CentOS 7 服务器。PHP、MariaDB 和 HTTPD 已安装并运行。所有服务都已启动并正常工作。浏览文档根显示
Forbidden
You don't have permission to access / on this server.
这是我服务器的文档根目录
DocumentRoot "/var/www/html/api/public"
文档根配置
<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>
这是welcome.conf 文件(/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
我能为这个问题做些什么?
解决方案
下面的服务器配置解决了我的问题。
授予文件夹权限并设置所有权
chown -R apache:apache /var/www/html/laravel
chmod -R 755 /var/www/html/laravel/storage
恢复安全
restorecon -R /var/www
禁用 SELinux
setenforce 0
推荐阅读
- node.js - 如何在 Google App Engine 标准环境中使用 Google Cloud Build 或其他方法设置环境变量?
- c# - 隐藏网格元素时更改 GridSplitter 行为
- java - 如何在android Studio中伪装android xml可点击链接?
- javascript - 在 Angular 应用程序上将 XML RSS 提要转换为 Json
- javascript - 如何更新文本指示器以显示进度条的进度?
- haskell - Haskell prettyprinter中的空(零高度)文档
- gitlab - 在 GitLab 的 docker 上运行邮递员脚本时出现 2 个错误。相同的脚本通过 Postman 和 Newman 运行良好
- unity3d - Unity 游戏对象由墙上的真实光点控制
- linq - 取一个并跳过子表中的其他重复项
- r - 将部分日期重置为 R 中的默认完整日期