Centos 7 phpmyadmin 403 禁止

Posted

技术标签:

【中文标题】Centos 7 phpmyadmin 403 禁止【英文标题】:Centos 7 phpmyadmin 403 Forbidden 【发布时间】:2015-10-29 11:12:21 【问题描述】:

当我尝试在 Centos 7 上运行 localhost/phpmyadmin 时出现权限错误:

Forbidden

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

我已经搜索并做了所有事情。

我的 /etc/httpd/conf.d/phpmyadmin.conf 文件是:

<Directory "/usr/share/phpmyadmin">
   Order Deny,Allow
#   Deny from all
   Allow from 127.0.0.1
</Directory>

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

我也用过:

Allow from all

我的 /usr/share/phpmyadmin/config.inc.php 是:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use scripts/setup.php
 *
 * All directives are explained in Documentation.html and on phpMyAdmin
 * wiki <http://wiki.phpmyadmin.net>.
 *
 * @version $Id$
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>

我还将权限更改为 /var/www/ "755" 并禁用了 SElinux。

我尝试的另一件事是在开始时使用它:

<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“sudo systemctl restart httpd.service” 我尝试了一切但没有运气。我仍然得到错误。有什么想法吗? 谢谢!

【问题讨论】:

Linux 区分大小写:/usr/share/phpMyAdmin vs /usr/share/phpmyadmin 为我关注这项工作***.com/questions/23235363/… 但我需要允许来自多个 IP 地址,您找到任何解决方案了吗? 【参考方案1】:

试试这样:

我只需要用我的 IP 和 Viola 替换 127.0.0.1 IP! 所以我想只是用“要求所有授予”替换“要求 ip 127.0.0.1”和“要求 ip ::1”就可以了。

【讨论】:

【参考方案2】:
  <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>

你提到的以上代码对我有用

【讨论】:

只是指出 - 评论中链接的另一个问题也提供了这个答案作为解决方法,但请记住向所有 IP 开放数据库的潜力。还提到了一些其他解决方案 - 请通读。话虽如此 - 这确实帮助了我,所以谢谢:)【参考方案3】:

不要用 yum 安装 phpmyadmin。它有很多错误要打开,尝试从phpmyadmin官方网站下载并将其解压缩到您的/var/www/html目录并将文件夹重命名为phpmyadmin并重新启动您的httpd服务。现在检查,完全不用担心。

【讨论】:

以上是关于Centos 7 phpmyadmin 403 禁止的主要内容,如果未能解决你的问题,请参考以下文章

在 centOS 上运行 phpmyadmin - 禁止错误 (403)

新的 xampp 安全概念:Access Forbidden Error 403 - Windows 7 - phpMyAdmin 与最新版本的 xampp 7.2.12

centOS 7.0 禁ip访问服务器

如何解决 XAMPP PHPMyAdmin 403 禁止错误

在centos 7中安装phpmyadmin

CentOs 7.*中配置安装phpMyAdmin的完整步骤记录