PhpMyAdmin错误:403禁止

时间:2016-09-18 12:18:34

标签: php mysql apache phpmyadmin

我安装了phpmyadmin,但当我在网站上时:ip / phpmyadmin我尝试登录,但是我没有重定向,所以我将其删除并重新安装。

从那时起,我甚至无法连接到该网站。在/etc/httpd/phpMyAdmin.conf文件中,我已经将我的ips添加了四次......

# phpMyAdmin - Web based MySQL browser written in php
# 
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

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

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </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>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </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>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

当我重新启动apache时,#service httpd restart,然后转到它仍然说的网站

禁止

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

Apache / 2.2.15(CentOS)服务器位于6gem.pw端口80

我无法找到任何修复,请帮助。

6 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并在此处分享了正确的解决方案:

要在phpMyAdmin目录设置中允许来自所有ips的连接,应更改如下代码:

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

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require all granted   # Add This to skip other requirements
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Allow,Deny  # change order to first apply allows, then deny
     Allow from All    # change this from deny to allow from all
     Allow from 127.0.0.1
     Allow from ::1
     Deny from 47.23.165.43  # Bad IPs which should be blocked
   </IfModule>
</Directory>

但是,如果您希望能够拒绝某些ip并为apache 2.4赋予所有其他ip,请更改# Apache 2.4 <RequireAny>部分,如下所示:

 # Apache 2.4
 <RequireAll> # change requirement to check all parameters
   Require all granted          # Add This to allow all requests
   Require not ip 47.23.165.43  # Bad IPs which should be blocked
   Require not ip 43.80         # Bad IPs which should be blocked
   Require not ip other.bad.ips # Bad IPs which should be blocked
 </RequireAll>

答案 1 :(得分:0)

编辑phpMyAdmin配置文件:

vim /etc/httpd/conf.d/phpMyAdmin.conf

然后将所有“全部拒绝”改为“拒绝无”和“允许形式无”改为“全部允许”。 这应该有效:)

答案 2 :(得分:0)

这适用于CentOS 7。

假设你已经安装了phpmyadmin和yum。

首先,通过在浏览器中加载http://localhost/phpmyadmin来检查localhost。 如果你收到禁止的消息,可能是因为没有安装php。 在我的情况下,我删除phpmyadmin安装,安装PHP并再次安装phpmyadmin: (以root身份) yum删除phpmyadmin yum安装php yum安装phpmyadmin service httpd restart

这些步骤解决了本地计算机中的问题。

现在,如果要为其他计算机添加权限(即192.168.1.10),请编辑/etc/httpd/conf.d/phpMyAdmin.conf。默认情况下,它仅允许访问localhost。

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

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
       Require ip 192.168.1.11
     </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>

重启httpd服务: service httpd restart

答案 3 :(得分:0)

在我的服务器上,发布了sql查询后,security2_module阻止了请求。

为phpmyadmin文件夹设置 SecRuleEngine 对我有用:

<Directory /usr/share/phpMyAdmin/>
    ...

    <IfModule security2_module>
        SecRuleEngine Off
    </IfModule>
    ...
</Directory>

答案 4 :(得分:0)

您还执行以下操作吗?这对我有帮助:

heights = [int(input(r + ', what is your height? ')) for r in recipients]

然后重新启动apache服务: systemctl重新启动httpd

答案 5 :(得分:0)

Require local

Require all granted

然后重新启动 xampp 服务。