在Fedora 32/31/30/29上安装和配置phpMyAdmin

时间:2020-02-23 14:32:15  来源:igfitidea点击:

在本教程中,我们将研究如何在Fedora 32/31/30/29上安装和配置phpMyAdmin。 PHPMyAdmin是一个用PHP编写的开源软件工具,旨在通过Web界面处理MySQL的管理。

phpMyAdmin支持在MySQL,MariaDB和Drizzle上的多种操作。它通常用于通过直观且易于使用的Web界面执行常见的数据库操作(管理数据库,表,列,关系,索引,用户,权限等)。

请按照以下步骤在Fedora 32/31/30/29上安装phpMyAdmin。

安装Apache HTTP Server和PHP

Apache HTTP服务器和PHP是phpMyAdmin必需的依赖项。首先安装它们:

sudo dnf -y install httpd php php-cli php-php-gettext php-mbstring php-mcrypt php-mysqlnd php-pear php-curl php-gd php-xml php-bcmath php-zip

配置httpd基本设置:

编辑配置文件/etc/httpd/conf/httpd.conf并设置:

ServerAdmin theitroad@localhost
ServerName  example.com
ServerTokens Prod

我们可以选择设置Keepalive:

KeepAlive On

启用并启动httpd服务:

sudo systemctl start httpd
sudo systemctl enable httpd

如果我们有防火墙运行,则同时启用http和https服务:

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

确认我们安装的PHP版本:

$php -v
PHP 7.3.4 (cli) (built: Apr  2 2019 13:48:50) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2016 Zend Technologies

可以通过将-m选项传递给php命令来查看已加载的扩展名。

$php -m

在文件/etc/php.ini中设置PHP时区

date.timezone = Africa/Nairobi

请参阅受支持时区的完整列表。

第2步:在Fedora 32/31/30/29上安装和配置phpMyAdmin

安装PHP和Apache之后,我们可以安装phpMyAdmin

sudo dnf -y install phpMyAdmin

我的Fedora机器上安装的版本是" 4.8.3"。

$rpm -qi phpMyAdmin
Name        : phpMyAdmin
Version     : 4.8.5
Release     : 2.fc30
Architecture: noarch
Install Date: Thu 02 Jan 2019 10:03:16 AM EAT
Group       : Unspecified
Size        : 26212455
License     : GPLv2+ and MIT and BSD
Signature   : RSA/SHA256, Sat 02 Nov 2019 08:33:08 PM EAT, Key ID ef3c111fcfc659b9
Source RPM  : phpMyAdmin-4.8.5-2.fc30.src.rpm
Build Date  : Sat 02 Nov 2019 01:53:43 PM EAT
Build Host  : buildvm-ppc64le-15.ppc.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://www.phpmyadmin.net/
Bug URL     : https://bugz.fedoraproject.org/phpMyAdmin
Summary     : Handle the administration of MySQL over the World Wide Web
Description :
phpMyAdmin is a tool written in PHP intended to handle the administration of
MySQL over the World Wide Web. Most frequently used operations are supported
by the user interface (managing databases, tables, fields, relations, indexes,
users, permissions), while you still have the ability to directly execute any
SQL statement.

Features include an intuitive web interface, support for most MySQL features
(browse and drop databases, tables, views, fields and indexes, create, copy,
drop, rename and alter databases, tables, fields and indexes, maintenance
server, databases and tables, with proposals on server configuration, execute,
edit and bookmark any SQL-statement, even batch-queries, manage MySQL users
and privileges, manage stored procedures and triggers), import data from CSV
and SQL, export data to various formats: CSV, SQL, XML, PDF, OpenDocument Text
and Spreadsheet, Word, Excel, LATEX and others, administering multiple servers,
creating PDF graphics of your database layout, creating complex queries using
Query-by-example (QBE), searching globally in a database or a subset of it,
transforming stored data into any format using a set of predefined functions,
like displaying BLOB-data as image or download-link and much more...

将对phpMyAdmin的访问限制为仅受信任的网络

sudo vim /etc/httpd/conf.d/phpMyAdmin.conf

编辑文件的第17行和第34行的" Require ip"行。

Require ip 127.0.0.1 192.168.18.0/24

保存更改并重新启动httpd服务

sudo systemctl restart httpd

访问phpMyAdmin界面

从我们喜欢的Web浏览器和列入白名单的网络访问[http://(主机名或者IP地址)/phpmyadmin /]

以数据库用户身份登录,以开始从phpMyAdmin Web界面管理数据库操作。

更改MySQL 8.0的身份验证插件

为了能够通过MySQL 8.0进行身份验证,请登录MySQL CLI并更改"身份验证插件"。

$mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names Jan be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ph/axo>vJe;789';
Query OK, 0 rows affected (0.11 sec)

mysql> QUIT
Bye