在服务器上安装 phpMyAdmin:分步指南

在服务器上安装 phpMyAdmin:分步指南

什么是 phpMyAdmin?
为了维护记录和用户信息,任何基于 Web 的应用程序都必须有一个数据库。

如果您是 Web 开发人员,您可能对 phpMyAdmin 很熟悉。对于任何经常处理数据库的开发人员来说,这是一个功能强大且用户友好的、基于 Web 的 MySQL 数据库管理工具。PhpMyAdmin 是用于操作 MySQL 数据库的图形化界面。在服务器上安装此工具之前,建议您已经安装好 Web 服务器(Apache/Nginx)和 MySQL(或 MariaDB、Percona)。开发人员可以使用终端执行 MySQL 查询。通过使用预定义的 MySQL 查询,可以在不了解技术细节的情况下执行简单的数据库操作。用户只需点击几下,就可以调试查询并执行复杂的数据库操作。

phpMyAdmin 分步安装指南
在本手册中,我们将逐步指导您在服务器上安装 phpMyAdmin。我们将涵盖从系统要求到安装方法和配置选项的所有内容。

注意:
开始之前,让我们先看看 phpMyAdmin 的系统要求。确保您的服务器满足这些要求对于顺利完成安装过程非常重要。

PhpMyAdmin 与大多数操作系统兼容,包括 Windows、macOS 和 Linux。它需要一个 Web 服务器(如 Apache 或 Nginx)、PHP(5.5.0 或更新版本)和一个数据库服务器(如 MySQL 或 MariaDB)。

现在我们已经确认了系统要求,让我们继续安装过程。

步骤 #1.

要安装它,只需输入以下命令:

yum install phpmyadmin /对于 CentOS/RHEL 系统
apt-get install phpmyadmin /对于 Debian/Ubuntu 系统

步骤 #2.

对于 CentOS/RHEL 系统,您需要在安装前启用 EPEL 仓库

yum install epel-release

安装完成后,您需要重启 Web 服务器或 php-fpm 服务,因为 phpMyAdmin 会一同安装额外的 PHP 模块

service httpd /或 php-fpm/ restart

步骤 #3

此条目适用于使用 Nginx 的情况。该工具本身安装在 /usr/share/phpMyAdmin 路径下。为了在访问站点时能显示该目录内容,您需要将其移动到站点目录下,或者将其挂载为一个目录。
第二种方法更可靠。在我们的案例中,站点路径是 /var/www/html,因此挂载命令如下:

cd /var/www/html
mkdir phpmyadmin
mount –bind /usr/share/phpMyAdmin/ phpmyadmin/

步骤 #4

此条目适用于使用 Apache 的情况。您需要打开配置文件 /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 // 这些设置允许从所有 IP 地址连接,可以使用 Require ip 选项进行限制。适用于 Apache 2.4 <RequireAll> Require all granted </RequireAll> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 // 与前一个块相同,但适用于较早版本的 Apache Order Deny,Allow Allow from All Deny from None # Allow from 127.0.0.1 # Allow from ::1 </IfModule> </Directory>

<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>

Apache 2.4 // 这些设置允许从所有 IP 地址连接,可以使用 Require ip 选项进行限制。适用于 Apache 2.4

<RequireAll> Require all granted </RequireAll> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 // 与前一个块相同,但适用于较早版本的 Apache Order Deny,Allow Allow from All Deny from None # Allow from 127.0.0.1 # Allow from ::1 </IfModule> </Directory>

这些目录不需要通过 HTTP 访问 – 取自原始的

phpMyAdmin 上游 tarball

<Directory /usr/share/phpMyAdmin/libraries/>
Order Deny,Allow
Allow from All
Deny from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
Order Deny,Allow
Allow from All
Deny from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
Order Deny,Allow
Allow from All
Deny from None
</Directory>

此配置可以防止 mod_security 在 phpMyAdmin 目录中过滤

SQL 等。这可能会破坏您的 mod_security 配置。

#<IfModule mod_security.c>

<Directory /usr/share/phpMyAdmin/>

SecRuleInheritance Off

</Directory>

#</IfModule>

步骤 #5

之后,再次重启 apache。
重启后,您可以通过访问 http://服务器名称或IP地址/phpmyadmin 来进入 phpMyAdmin,并使用数据库凭据登录。

为什么应该考虑在 Debian 上安装 phpMyAdmin?
PhpMyAdmin 是一个广泛使用的、基于 Web 的 MySQL 数据库管理工具。它提供了一个直观且用户友好的界面来管理数据库、表和执行查询。虽然 phpMyAdmin 可以安装在各种操作系统上,但有几个令人信服的理由说明为什么您可能考虑在 Debian 而非 Mac OS 或 Ubuntu 上使用它。

  1. 稳定性和可靠性:Debian 以其作为操作系统的稳定性和可靠性而闻名。使用 Debian,您可以确信拥有一个稳定且安全的环境来管理您的数据库。

  2. 软件包管理:Debian 的软件包管理系统,即高级软件包工具(APT),是其关键优势之一。它简化了软件包(包括 phpMyAdmin)的安装和管理。APT 确保您可以轻松地安装、更新和删除 phpMyAdmin 及其依赖项,没有任何麻烦。

  3. 安全性:在管理数据库时,安全性是一个关键方面。Debian 高度重视安全性,并提供定期安全更新以解决任何漏洞。这确保了您的 phpMyAdmin 安装保持安全并免受潜在威胁。

  4. 社区和支持:Debian 拥有庞大且活跃的用户和开发者社区。这个充满活力的社区提供广泛的支持和文档,使得在 Debian 上使用 phpMyAdmin 时可能出现的任何问题都更容易解决。您可以依靠 Debian 社区提供及时的帮助和指导。

  5. 定制化和灵活性:Debian 提供了高度的定制化和灵活性。您可以根据自己的特定要求和偏好来定制 Debian 安装。这种灵活性也扩展到了 phpMyAdmin,允许您根据自己的需要对其进行配置,并将其无缝集成到您现有的基础设施中。

  6. 长期支持:Debian 以其长期支持版本而闻名。这意味着一旦您安装了 Debian,您就可以在较长时期内(通常约为五年)受益于安全更新和错误修复。

Telegram
Telegram服务器销售@IDCSELL