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

时间:2014-04-23 05:20:36

标签: php mysql phpmyadmin

您好我已经在我的centos机器上安装了phpmyadmin,当我尝试通过浏览器点击phpmyadmin时出现此错误:

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

我的phpmyadmin.conf文件包含以下内容:

# 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/>
   <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>

请帮我解决这个问题。任何领导都表示赞赏。

由于

12 个答案:

答案 0 :(得分:90)

上面的配置都没有在我的CentOS 7服务器上工作。经过几个小时的搜索,这对我有用:

编辑文件phpMyAdmin.conf

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

并将其替换为顶部:

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

答案 1 :(得分:36)

在CENTOS7上的全新安装中,我尝试了上述方法(编辑phpMyAdmin.conf并添加Require all grant),它仍然无法正常工作。这是解决方案:安装mod_php模块:

$ sudo yum install php

然后重启httpd:

$ sudo systemctl restart httpd

瞧!

答案 2 :(得分:29)

您需要按照以下步骤操作:

查找阅读后面的行

Require ip 127.0.0.1

替换为您的工作站IP地址:

Require ip 10.1.3.53

再次找到以下行:

Allow from 127.0.0.1

替换如下:

Allow from 10.1.3.53

同时找到deny from all并在整个文件中对其进行评论。

保存并关闭文件。Restart Apache httpd server

# service httpd restart

答案 3 :(得分:6)

编辑文件:sudo nano /etc/httpd/conf.d/phpMyAdmin.conf并将以下内容替换为:

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8
   <IfModule mod_authz_core.c>
     # Apache 2.4
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
   </IfModule>
</Directory>

重启Apache:service httpd restart

(phpMyAdmin v4.0.10.8)

答案 4 :(得分:3)

得票最多的答案问题是它没有解释解决方案的原因。

对于行Require ip 127.0.0.1,您应该添加计划从浏览器访问phpMyAdmin的主机的IP地址。例如Require ip 192.168.0.100Require ip 127.0.0.1允许localhost访问phpMyAdmin。

进行更改后重启apache(httpd)。我建议在localhost上进行测试,或者使用像curl这样的命令行工具来实现http GET,并且没有其他配置问题。

答案 5 :(得分:2)

首先编辑文件/etc/httpd/conf.d/phpMyAdmin.conf并将其他行添加到目录设置中:

<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from 192.168.1.0/15
</Directory>

如果您想允许访问所有人,那么您可以将其更改为:

<Directory /usr/share/phpMyAdmin/>
order allow,deny
allow from all
</Directory>

允许文件的所有部分。

重新启动(服务httpd重启)足以解决这个问题。

经过2天的严谨研究后我发现了这一点(找到它here)并且对我来说非常合适。

答案 6 :(得分:2)

允许所有人:

#Require ip 127.0.0.1
#Require ip ::1
Require all granted

答案 7 :(得分:0)

您可以直接转到phpmyadmin.conf文件并将“deny from all”更改为“allow from all”。 它对我有用,希望它对你也有用。

答案 8 :(得分:0)

Centos 7 php安装随附已安装并启用了ModSecurity软件包,该软件包会阻止Web访问phpMyAdmin。在phpMyAdmin.conf的末尾,您应该找到

None

为您提供问题的答案。通过添加

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

在“目录/ usr / share / phpMyAdmin /”块中,可以解决对phpmyadmin的“拒绝访问”,但是可能会产生安全问题。

答案 9 :(得分:0)

Find your IP address 并使用从上面的链接获得的工作站IP地址替换您看到的127.0.0.1。

. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .

最后不要忘记重启服务器

sudo systemctl restart httpd.service

答案 10 :(得分:0)

至少具有最新版本的phpmyadmin 5.0.2+

检查实际安装是否正确完成,

我的副本已被复制到Linux机器上的子文件夹中,而不是位于

/usr/share/phpmyadmin/

答案 11 :(得分:0)

在应用服务器中,我遇到了同样的问题,我转到了“C:\AppServ\Apache24\conf\extra”文件夹,我从

修改了 httpd-vhosts.conf 文件
<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs"
#ServerName www.example.com:80
</VirtualHost>

<VirtualHost _default_:80>
DocumentRoot "C:\AppServ\www"
#ServerName www.example.com:80
</VirtualHost>