我有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
该问题我该怎么办?
答案 0 :(得分:0)
创建此.htaccess文件并将其放在您的应用文件夹中。
RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L]
答案 1 :(得分:0)
以下服务器配置已解决我的问题。
授予文件夹权限和设置所有权
"text message".include?(' ') #=> true
"text_message".include?(' ') #=> false
恢复安全性
chown -R apache:apache /var/www/html/laravel
chmod -R 755 /var/www/html/laravel/storage
禁用SELinux
restorecon -R /var/www