centos 抱歉,您没有权限访问该版块

2fjabf4q  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(85)

我在主机上安装了httpd,并对httpd.conf文件进行了如下修改

ServerRoot "/etc/httpd"

Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

<Directory />
    AllowOverride none
    Require all granted
</Directory>
DocumentRoot "/home/admin/domains/morabi.app/public_html"

<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks

    AllowOverride None

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

字符串
当我在浏览器中加载我的IP地址时,它有“禁止您没有权限访问/在此服务器上。”错误。和/home/admin/domains/morabi.app权限是755也文件加载,但我的IP http://x.x.x.x/有禁止错误

0mkxixxg

0mkxixxg1#

您需要向其添加以下内容:

<Directory "/home/admin/domains/morabi.app/public_html">
# Learn more about this at https://httpd.apache.org/docs/2.4/mod/core.html#options
Options Indexes FollowSymLinks

# Learn more about this at https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride
AllowOverride All

# The solution for your error, allows your files to be served, learn more about this at https://httpd.apache.org/docs/2.4/howto/access.html
Require all granted
</Directory>

字符串
重启Apache。
这是很多人忘记的,有些人不知道的,请大家注意这一点。

编辑

提示:运行这些命令前请备份,如果文件出现问题,我不负责。

尝试通过在终端内的morabi.app内运行ls -la来检查文件夹public_html的所有者,如果它不是您的用户或Apache,请尝试在目录morabi.app中运行此命令:
确保你是作为你使用的主用户运行这个,我建议你不要把它改为root。

chown $USER:$USER public_html -R


上面的命令将更改文件夹的所有者和其中的文件。如果将所有者更改为运行命令的用户不起作用,请将$USER更改为apache,但始终要像我上面所说的那样备份。

相关问题