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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23235363/
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-25 16:35:58  来源:igfitidea点击:

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

phpmysqlphpmyadmin

提问by Megha Sharma

Hi I have installed phpmyadmin on my centos machine and when I try to hit phpmyadminthrough my browser I get this error :

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

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

My phpmyadmin.conffile has following content:

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

Kindly help me resolve this issue. Any lead is appreciated.

请帮我解决这个问题。任何线索表示赞赏。

Thanks

谢谢

采纳答案by Megha Sharma

You need to follow the following steps:

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

Find line that read follows

查找以下行

Require ip 127.0.0.1

Replace with your workstation IP address:

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

Require ip 10.1.3.53

Again find the following line:

再次找到以下行:

Allow from 127.0.0.1

Replace as follows:

替换如下:

Allow from 10.1.3.53

Also find deny from alland comment it in the entire file.

还要deny from all在整个文件中查找并注释它。

Save and close the file.Restart Apache httpd server:

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

# service httpd restart

Edit: Since this is the selected answer and gets best visibility ... please also make sure that PHP is installed, otherwise you get same Forbiddenerror.

编辑:由于这是选定的答案并获得最佳可见性...还请确保已安装 PHP,否则您会遇到相同的Forbidden错误。

回答by Hyder B.

None of the configuration above worked for me on my CentOS 7 server. After hours of searching, that what worked for me:

以上配置都不适用于我的 CentOS 7 服务器。经过数小时的搜索,这对我有用:

Edit file phpMyAdmin.conf

编辑文件 phpMyAdmin.conf

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

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

And replace the existing <Directory> ... </Directory>node with the following:

并将现有<Directory> ... </Directory>节点替换为以下内容:

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

回答by Edouard Thiel

On a fresh install on CENTOS7 I have tried the above methods (edit phpMyAdmin.conf and add Require all granted), it still does'nt work. Here is the solution : install the mod_php module :

在 CENTOS7 上全新安装时,我尝试了上述方法(编辑 phpMyAdmin.conf 并添加 Require all allowed ),它仍然不起作用。这是解决方案:安装 mod_php 模块:

$ sudo yum install php

then restart httpd :

然后重启httpd:

$ sudo systemctl restart httpd

and voila !

瞧!

回答by emotality

Edit file: sudo nano /etc/httpd/conf.d/phpMyAdmin.confand replace yours with following:

编辑文件: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>

Restart Apache: service httpd restart

重启阿帕奇: service httpd restart

(phpMyAdmin v4.0.10.8)

(phpMyAdmin v4.0.10.8)

回答by wrr

To allow from all:

允许所有人:

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

回答by Alvin Bunk

The problem with the answer with the most votes is it doesn't explain the reasoning for the solution.

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

For the lines Require ip 127.0.0.1, you should instead add the ip address of the host that plans to access phpMyAdmin from a browser. For example Require ip 192.168.0.100. The Require ip 127.0.0.1allows localhost access to phpMyAdmin.

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

Restart apache (httpd) after making changes. I would suggest testing on localhost, or using command line tools like curl to very a http GET works, and there is no other configuration issue.

更改后重新启动 apache (httpd)。我建议在 localhost 上进行测试,或者使用 curl 之类的命令行工具来非常有效地进行 http GET,并且没有其他配置问题。

回答by Syed Zuber

First edit the file /etc/httpd/conf.d/phpMyAdmin.conf and add the additional line to the directory settings:

首先编辑文件 /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>

If you wanted to allow access to everybody then you could just change it to:

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

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

Allow in all sections of the file.

允许在文件的所有部分。

A restart (service httpd restart) is enough to pick this up.

重新启动(service httpd restart)就足以解决这个问题。

I found this after 2 days rigorous research, (find it here) and worked just right for me.

经过 2 天的严格研究,我发现了这个(在此处找到)并且非常适合我。

回答by Laurent Mortier

Centos 7 php install comes with the ModSecurity package installed and enabled which prevents web access to phpMyAdmin. At the end of phpMyAdmin.conf, you should find

Centos 7 php 安装随附安装并启用的 ModSecurity 包,可防止 Web 访问 phpMyAdmin。在 phpMyAdmin.conf 的末尾,你应该找到

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

which gives you the answer to the problem. By adding

这给了你问题的答案。通过添加

    SecRuleEngine Off

in the block "Directory /usr/share/phpMyAdmin/", you can solve the 'denied access' to phpmyadmin, but you may create security issues.

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

回答by Faisal Naseer

Find your IP addressand replace where ever you see 127.0.0.1 with your workstation IP address you get from the link above.

找到您的 IP 地址并将您看到的 127.0.0.1 替换为您从上面的链接中获得的工作站 IP 地址。

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

and in the end don't forget to restart the server

最后不要忘记重启服务器

sudo systemctl restart httpd.service

回答by Boris

With the latest version of phpmyadmin 5.0.2+ at least

至少 phpmyadmin 5.0.2+ 最新版本

Check that the actual installation was completed correctly,

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

Mine had been copied over into a sub folder on a linux machine rather that being at the

我的已被复制到 linux 机器上的子文件夹中,而不是在

/usr/share/phpmyadmin/