禁止访问:您无权访问此服务器上的/(centos 7)

我在主机上安装了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/禁止错误

woshiwuchao1 回答:禁止访问:您无权访问此服务器上的/(centos 7)

您需要在其中添加以下内容,

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

这是许多人忘记的事情,有些人不知道。请注意这一点。

编辑:
在目录配置中添加了 public_html 字样

另一个提示

  
    

在运行这些命令之前先备份一下,如果文件有任何不良情况,我概不负责。

  

尝试通过在终端内的morabi.app中运行ls -la来检查文件夹public_html的所有者,如果不是您的用户或apache,请尝试在目录morabi.app中运行以下命令:

  

请确保您以您使用的主要用户身份运行它,建议您不要将其更改为root用户。

chown $USER:$USER public_html -R

以上命令将更改文件夹的所有者和其中的文件。如果将所有者更改为运行命令的用户不起作用,请将$USER更改为apache,但是请务必先备份一下。

本文链接:https://www.f2er.com/2863416.html

大家都在问