禁止:您无权访问/在此服务器上(centos 7)
Forbidden: You don't have permission to access / on this server (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/ 已被禁止错误
您需要添加以下内容,
<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.
尝试在终端morabi.app内通过运行ls -la
检查文件夹public_html的所有者,如果不是您的用户或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
上述命令将更改文件夹的所有者和其中的文件。如果将所有者更改为用户 运行 命令不起作用,请将 $USER
更改为 apache
,但请始终按照我上面所说的进行备份。
我在宿主机上安装了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。
这是许多人忘记的事情,有些人不知道。请注意这一点。
编辑:
在目录配置
另一个提示
Take a backup before running these commands, I am not responsible if anything bad happens to the files.
尝试在终端morabi.app内通过运行ls -la
检查文件夹public_html的所有者,如果不是您的用户或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
上述命令将更改文件夹的所有者和其中的文件。如果将所有者更改为用户 运行 命令不起作用,请将 $USER
更改为 apache
,但请始终按照我上面所说的进行备份。