服务器版本信息:
[root@redhat8 ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@redhat8 ~]#
[root@redhat8 ~]# uname -r
4.18.0-193.el8.x86_64
关闭SELinux:(默认是开启的,要关闭)
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
笺注:实验中是使用本地光盘作为Yum源进行安装的。
安装Apache:
dnf -y install http*
启动Apache:
systemctl start httpd
systemctl enable httpd
安装MariaDB:
dnf -y install mariadb-server mariadb
启动MariaDB:
systemctl start mariadb
systemctl enable mariadb
安装PHP:
yum -y install php php-fpm php-mysqlnd php-gd php-xml php-mbstring
重启防火墙(Firewalld)服务:
[root@centos8 ~]# systemctl restart firewalld
在防火墙打开TCP 80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
查看防火墙所有打开的端口:
[root@centos8 ~]# firewall-cmd --zone=public --list-ports
80/tcp
Apache的版本信息:
[root@centos8 ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built: Jun 8 2020 20:14:33
Apache的主配置文件:
[root@centos8 ~]# find / -name httpd.conf
/etc/httpd/conf/httpd.conf
[root@centos8 ~]# vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html" #默认站点的根目录
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None #不开启伪静态
Require all granted
</Directory>
PHP的版本信息:
[root@centos8 ~]# php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
PHP的配置文件:
[root@centos8 ~]# find / -name php.ini
/etc/php.ini
MariaDB的版本信息:(默认情况下,数据库管理员root没有密码的)
[root@centos8 ~]# mysql -u"root" -V
mysql Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1
MariaDB的最大连接数:
[root@centos8 ~]# mysql -u"root" -e "show variables like '%max_connections%';"
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| extra_max_connections | 1 |
| max_connections | 151 |
+-----------------------+-------+
MariaDB的主配置文件:
[root@centos8 ~]# find / -name my.cnf
/etc/my.cnf
登录MariaDB:(不指定用户,就是使用数据库管理员root)
创建数据库本地用户zhuohua@localhost,并赋权:
MariaDB [(none)]> grant all on *.* to zhuohua@localhost identified by '888';
查看数据库本地用户zhuohua@localhost的权限:
MariaDB [(none)]> show grants for zhuohua@localhost;
+-------------------------------------------------------------------------------------------------------------------------+
| Grants for zhuohua@localhost |
+-------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zhuohua'@'localhost' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8886EBFCF' |
+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
查看数据库管理员root@localhost的权限:
MariaDB [(none)]> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.000 sec)
###############
###############
phpMyAdmin(PHP语言编写的,是远程管理MySQL/MariaDB的工具)
下载phpMyAdmin:https://pan.baidu.com/s/1ca0GQSzxnSjXIUEPNmBX3Q 提取码:bl19
安装phpMyAdmin:
tar -zxvf phpMyAdmin-4.4.15.6-all-languages.tar.gz -C /var/www/html/
cd !$
mv phpMyAdmin-4.4.15.6-all-languages/ phpMyAdmin
cd !$
mv config.sample.inc.php config.inc.php
重启Apache:
[root@centos8 ~]# systemctl restart httpd
phpMyAdmin的配置文件:
[root@centos8 phpMyAdmin]# pwd
/var/www/html/phpMyAdmin
[root@centos8 phpMyAdmin]# vi config.inc.php
注释:
这里的主机地址默认为localhost,即本地连接,无需打开防火墙的TCP 3306端口;
打开防火墙的TCP 80端口,客户端就可以正常访问phpMyAdmin的管理页面了;
客户端远程登录 phpMyAdmin:(建议使用Frefox浏览器)
http://192.168.168.154/phpMyAdmin/
解决方法:
[root@centos8 ~]# yum -y install php-json
[root@centos8 ~]# systemctl restart httpd
使用数据库本地用户zhuohua@localhost登录phpMyAdmin:
有一个告警:
解决方法:
修改phpMyAdmin的配置文件:
$cfg['blowfish_secret'] = '123'; #任意密码都可以
如下图:
重启Apache:
[root@centos8 phpMyAdmin]# systemctl restart httpd
告警消失了:
查看数据库用户:
更改当前数据库用户zhuohua@localhost的密码:
当前数据库用户zhuohua@localhost的密码的确更改了^_^
创建数据库,并指定其字符集:
使用phpMyAdmin里的SQL查询:(在指定数据库里,创建表)
use db1;
CREATE table t1(id int);
注释:还要点击右下角的“执行”按键。
创建表成功:
######
给数据库管理员root设置密码:
use mysql;
update user set password=password('mima') where user='root';
flush privileges;
现在数据库管理员root要通过密码验证才能登录MariaDB:
mysql -u"root" -p"mima"
数据库管理员root有了密码后,才能登录phpMyAdmin:
注释:只有数据库管理员root才能编辑数据库用户的权限。
###
给数据库管理员root清空密码:
MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set password=password('') where user='root';
MariaDB [mysql]> flush privileges;
数据库管理员root又可以无密码登录MariaDB了:
相关文章:
CentOS8_Yum仓库
CentOS8_Apache2.4基于域名的虚拟主机+代理虚拟主机
Apache2.4的MPM模式(event)
CentOS8_云锁+Apache
CentOS8安装服务器安全狗、Apache版网站安全狗
CentOS8_在Docker中安装MariaDB
CentOS8_在Docker中安装LAMP
CentOS8_在Docker中安装Zabbix4.4.5
CentOS8_Apache2.4反向代理
CentOS8安装Flask+Apache2.4反向代理
CentOS8使用Python3脚本管理MariaDB
MariaDB的最大连接数/最大可打开表数/最大可打开文件数
MariaDB主从同步
CentOS8_Tomcat8+JDK1.7+MySQL/MariaDB
CentOS8_Tomcat9+JDK1.9+MySQL/MariaDB
CentOS8安装LNMP+phpMyAdmin
CentOS8_LAMP_编译安装Zabbix5.0.12
Apache2.2+MySQL5.6+PHP5.6+phpMyAdmin+GLPI |