简体   繁体   English

PhpMyAdmin 错误:403 禁止

[英]PhpMyAdmin error: 403 forbidden

I had phpmyadmin installed but when i was on the site : ip/phpmyadmin i tried to logon, but i couldent, it would not redirect me so I removed it and reinstalled.我安装了 phpmyadmin,但是当我在网站上时:ip/phpmyadmin 我试图登录,但我无法登录,它不会重定向我,所以我将其删除并重新安装。

From then on I cant even connected to the site.从那时起,我什至无法连接到该站点。 In the /etc/httpd/phpMyAdmin.conf file I have added my ips four times like so...在 /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>

When I restart apache, # service httpd restart, and then go onto the site it still says当我重新启动 apache 时,#service httpd restart,然后进入该站点仍然显示

Forbidden禁止的

You don't have permission to access /phpMyAdmin/ on this server.您无权访问此服务器上的 /phpMyAdmin/。

Apache/2.2.15 (CentOS) Server at 6gem.pw Port 80 Apache/2.2.15 (CentOS) 服务器在 6gem.pw 端口 80

I cant find any fixes, please help.我找不到任何修复,请帮助。

I had the same problem and sharing the correct solution here:我遇到了同样的问题并在这里分享了正确的解决方案:

To allow connections from All ips in phpMyAdmin directory settings you should change the code like this:要允许来自 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>

but if you want to be able to deny some ips and accpet all other ips for apache 2.4 change # Apache 2.4 <RequireAny> part as this:但是,如果您希望能够拒绝某些 ips 并接受 apache 2.4 的所有其他 ips,请更改# 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>

Edit your phpMyAdmin configuration file:编辑您的 phpMyAdmin 配置文件:

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

Then change all "Deny from All" to "Deny from None" and "Allow form None" to "Allow from All".然后将所有“全部拒绝”更改为“无拒绝”,将“允许形式无”更改为“全部允许”。 That should work :)那应该工作:)

This works for me under CentOS 7.这在 CentOS 7 下对我有用。

Assuming you have installed phpmyadmin with yum.假设您已经使用 yum 安装了 phpmyadmin。

First, check in the localhost by loading http://localhost/phpmyadmin in your browser.首先,通过在浏览器中加载http://localhost/phpmyadmin来检查本地主机 If you get the forbidden message, probably is because php is not installed.如果你收到禁止信息,可能是因为没有安装php。 In my case, I remove phpmyadmin installation, install php and install phpmyadmin again: (as root) yum remove phpmyadmin yum install php yum install phpmyadmin service httpd restart就我而言,我删除 phpmyadmin 安装,安装 php 并再次安装 phpmyadmin:(以 root 身份) yum remove phpmyadmin yum install php yum install phpmyadmin service httpd restart

These steps fixed the problem in the local machine.这些步骤解决了本地机器中的问题。

Now, edit /etc/httpd/conf.d/phpMyAdmin.conf if you want to add permissions for another machine (ie 192.168.1.10).现在,如果您想为另一台机器(即 192.168.1.10)添加权限,请编辑 /etc/httpd/conf.d/phpMyAdmin.conf。 By default, it allows access only for 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>

Restart httpd service: service httpd restart重启 httpd 服务: service httpd restart

On my server it was security2_module blocking requests after a sql query was posted.在我的服务器上,发布 sql 查询后,security2_module 阻塞了请求。

Setting SecRuleEngine Off for the phpmyadmin folder did the trick for me:为 phpmyadmin 文件夹设置SecRuleEngine Off对我有用

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

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

Did you perform the following as well?您是否也执行了以下操作? This helped me:这帮助了我:

    mkdir /usr/share/phpMyAdmin/tmp

    chmod 777 /usr/share/phpMyAdmin/tmp

    chown -R apache:apache /usr/share/phpMyAdmin
    
    yum install -y policycoreutils-python-utils
    
    semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/phpMyAdmin/'
    
    semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/phpMyAdmin/tmp(/.*)?'
    
    restorecon -Rv '/usr/share/phpMyAdmin/'

Then restart apache service: systemctl restart httpd然后重启apache服务: systemctl restart httpd

Require local

to

Require all granted

then restart the xampp services.然后重新启动 xampp 服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM