阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

151次阅读
没有评论

共计 2150 个字符,预计需要花费 6 分钟才能阅读完成。

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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计2150字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中