apache - 禁止 : You don't have permission to access/on this server (centos 7)

标签 apache permissions centos httpd.conf httpforbiddenhandler

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

最佳答案

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

<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

另一个提示

Take a backup before running these commands, I am not responsible if anything bad happens to the files.



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

Make sure you are running this as your primary user which you use, I suggest you not to change it to root.


chown $USER:$USER public_html -R

上面的命令将更改文件夹的所有者和其中的文件。更改$USERapache如果将所有者更改为运行命令的用户不起作用,但如我上面所说,请务必在之前进行备份。

关于apache - 禁止 : You don't have permission to access/on this server (centos 7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59477174/

相关文章:

PHP Codeigniter 错误无法打开流 : Permission denied

linux - Golang csv 在 linux 上写空

centos - 在 *UNIX 系统下,哪个命令可用于通过 chef-client 提取当前运行列表的 Recipe ?

apache - 由于新的 Log4j 漏洞,Apache HTTP Server 可以允许反向脱壳吗?

java - 部署到 weblogic

apache - 在树莓派上设置 SSL

jenkins - 如何在 Jenkins 中管理用户权限?

apache - "insufficient memory for the Java Runtime"来自 Perl-CGI 通过 apache

jquery - Apache 阻止多个请求?

java - 当 URLResourceLoader 与 Velocity 一起使用时无法加载模板