无法从 Web 浏览器访问 phpmyadmin
Posted
技术标签:
【中文标题】无法从 Web 浏览器访问 phpmyadmin【英文标题】:cannot access phpmyadmin from web browser 【发布时间】:2019-01-19 22:41:52 【问题描述】:操作系统:CentOS Linux 7 (Core) x86-64
我已经安装了 phpmyadmin 和 httpd (apache - httpd-2.4.6-80.el7.centos.1.x86_64) ;
我已经从 /etc/httpd/conf.d/phpMyAdmin.conf 配置/编辑 phpmyadmin
重启 Apache 后出现 Forbidden 错误 您无权访问此服务器上的 /phpMyAdmin/。
我的 conf 文件,这里 42.108.56.117(我已经编辑过)是我自己的 IP,4.4.4.4 是我的服务器 IP。
# 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 42.108.56.117
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 42.108.56.117
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 42.108.56.117
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 42.108.56.117
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>
我也尝试过使用 *** 中的这个解决方案,但没有奏效,有人知道这个问题的答案吗?
替换为:
<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/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
仍在寻找这个问题的答案......
【问题讨论】:
【参考方案1】:好的,我找到了答案,
我首先将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>
然后重新启动 apache 并完成,它对我来说工作正常。
如果有人遇到这个问题,请不要犹豫在这里发表评论,我一定会以任何可能的方式提供帮助。美好的一天!
【讨论】:
以上是关于无法从 Web 浏览器访问 phpmyadmin的主要内容,如果未能解决你的问题,请参考以下文章