手机版
你好,游客 登录 注册
背景:
阅读新闻

如何在CentOS 7/RHEL 7上安装phpMyAdmin

[日期:2018-12-04] 来源:Linux公社  作者:醉落红尘 [字体: ]

phpMyAdmin是用于管理MySQL,MariaDB和Drizzle服务器的基于Web的管理工具。 它有助于执行数据库活动,如创建,删除,查询,表,列,关系,索引,用户,权限等。

本指南将帮助您在CentOS 7 / RHEL 7上安装phpMyAdmin。

在安装phpMyAdmin之前,必须在服务器上安装LAMP Stack。

在CentOS 7上安装phpMyAdmin

phpMyAdmin在EPEL中可用,因此安装EPEL存储库rpm。

rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

使用以下命令安装phpMyAdmin。

yum -y install phpmyadmin

配置phpMyAdmin

phpMyAdmin将配置文件放在/etc/httpd/conf.d目录中。 它具有访问权限的规则和权限。

默认情况下,phpMyAdmin只能从localhost访问,以改变它; 我们必须编辑phpMyAdmin.conf文件。

在CentOS 7中,Web访问由mod_authz_core.c模块管理; 所以正常的允许或拒绝规则即使你修改也行不通。

vi /etc/httpd/conf.d/phpMyAdmin.conf

默认配置如下所示。

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>   

请注释掉需要ip 127.0.0.1并且要求ip :: 1然后在注释行中添加要求全部授权,它将如下所示。

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

<Directory /usr/share/phpMyAdmin/setup/>
  <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>

重启服务。

systemctl restart httpd

配置防火墙以允许来自外部网络的HTTP请求。

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

访问phpMyAdmin

现在从浏览器访问phpMyAdmin,URL将是:

http://localhost/phpMyAdmin

或者

http://your-ip-address/phpMyAdmin

使用root(DB admin)或任何数据库用户登录。

如何在CentOS 7/RHEL 7上安装phpMyAdmin

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址https://www.linuxidc.com/Linux/2018-12/155690.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款