MySQL phpmyadmin - 禁止 - 您无权访问此服务器上的 /phpmyadmin/

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42875032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:16:01  来源:igfitidea点击:

phpmyadmin - Forbidden - You don't have permission to access /phpmyadmin/ on this server

mysqlapachephpmyadmincentos

提问by Exbi

I'm aware this has been asked many times before but all of the answers seem the same and none of them work for me.

我知道这之前已经被问过很多次了,但所有的答案似乎都一样,而且没有一个对我有用。

I want to access the phpmyadmin GUI from something other than the localhost.

我想从本地主机以外的东西访问 phpmyadmin GUI。

I'm getting the error "Forbidden - You don't have permission to access /phpmyadmin/ on this server." in the browser.

我收到错误“禁止 - 您无权访问此服务器上的 /phpmyadmin/。” 在浏览器中。

I'm using CentOS7, Apache 2.4.6 and phpMyAdmin-4.4.15.10-1.el7.

我使用 CentOS7、Apache 2.4.6 和 phpMyAdmin-4.4.15.10-1.el7。

I've tried this:

我试过这个:

<Directory /usr/share/phpMyAdmin/>
  Order Allow,deny
  Allow from all
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
  Order Allow,deny
  Allow from all
</Directory>

Most people seem to suggest I can just do:

大多数人似乎建议我可以这样做:

<IfModule mod_authz_core.c>
    # Apache 2.4
    <RequireAny>
        Require all granted
    </RequireAny>
</IfModule>

Or:

或者:

<IfModule mod_authz_core.c>
    # Apache 2.4
    <RequireAny>
        Require ip 192.168.1.6
    </RequireAny>
</IfModule>

But none of that works.

但这些都不起作用。

This is the current state:

这是目前的状态:

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 192.168.1.6
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Allow,Deny
     Allow from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

Still getting:

仍然得到:

Forbidden

You don't have permission to access /phpmyadmin/ on this server.

禁止的

您无权访问此服务器上的 /phpmyadmin/。

EDIT-

编辑-

Just as additional information, I have disabled SELinux and made sure permissions on /usr/share/phpMyAdmin are correct.

作为附加信息,我已禁用 SELinux 并确保 /usr/share/phpMyAdmin 上的权限正确。

EDIT AGAIN-

再次编辑-

I've now tried this...

我现在已经尝试过这个...

<Directory /usr/share/phpMyAdmin/>
        Require all granted
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
        Require all granted
</Directory>

Which is surely as basic as you can get and yet I still get the error?

这肯定是您可以获得的基本知识,但我仍然收到错误消息?

回答by Md Humayun Kabir

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
         Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Allow,Deny
     Allow from All
   </IfModule>
</Directory>

回答by Exbi

Got this working eventually. There were a few problems at once, which was getting in the way of troubleshooting the main problem...

最终得到了这个工作。一下子出现了一些问题,这妨碍了对主要问题的故障排除……

First, edit phpMyAdmin.conf...

首先,编辑phpMyAdmin.conf...

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
         Require ip 192.168.1.6
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

OR

或者

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
         Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

You also need to make sure that/usr/share/phpMyAdmin is not only readable but also executable for the Apache user. I just recursively chmodded it to 777.

您还需要确保 /usr/share/phpMyAdmin 不仅对 Apache 用户可读而且可以执行。我只是递归地将它修改为 777。

You also need to add the following to /etc/httpd/conf/httpd.conf:

您还需要将以下内容添加到 /etc/httpd/conf/httpd.conf:

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

Check /var/log/httpd/error_log to see what your particular error is at each step.

检查 /var/log/httpd/error_log 以查看每个步骤中的特定错误。