一.更换YUM源
[root@localhost~]#wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
二.安装Apache服务及其扩展包
[root@localhost~]#yum-yinstallhttpdhttpd-manualmod_sslmod_perlmod_auth_mysql
三.启动Apache服务并测试
[root@localhost~]#systemctlstarthttpd.service
四.下载并安装MySQL官方的Yum Repository。
[root@localhost~]#rpm-emariadb-libs--nodeps# 删除原先的数据库 [root@localhost~]#yuminstall-yhttps://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm[root@localhost~]#yuminstall-yhttps://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm[root@localhost~]#yuminstall-yhttps://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm[root@localhost~]#yuminstall-yhttps://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm[root@localhost~]#yuminstall-yhttps://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
五.查看MySQL初始密码,配置数据库相关参数
[root@localhost~]#systemctlstartmysqld.service#开启数据库服务[root@localhost~]#grep"password"/var/log/mysqld.log#Xx+Q)4AWBUp)这个是我的初始密码2022-01-21T02:32:11.011259Z1 [Note] Atemporarypasswordisgeneratedforroot@localhost: Xx+Q)4AWBUp)
六.配置数据库root密码(注意每条命令的分号;)
[root@localhost~]#mysql-uroot-ppassword: mysql>setglobalvalidate_password_policy=0; #修改密码安全策略为低mysql>ALTERUSER'root'@'localhost'IDENTIFIEDBY'12345678'; #这里我设的密码为12345678mysql>GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'12345678'; #执行以下命令,授予root用户远权限mysql>exit#退出[root@localhost~]#systemctlrestartmysqld.service重启数据库
七.安装相关的PHP环境,并测试:
[root@localhost~]#yum-yinstallphpphp-mysqlgdphp-gdgd-develphp-xmlphp-commonphp-mbstringphp-ldapphp-pearphp-xmlrpcphp-imap[root@localhost~]#echo"<?php phpinfo(); ?>">/var/www/html/phpinfo.php[root@localhost~]#systemctlrestarthttpd#重启阿帕奇服务
八.下载配置phpMyAdmin
[root@localhost ~]#mkdir -p /var/www/html/phpmyadmin [root@localhost ~]#wget --no-check-certificate https://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip [root@localhost ~]#yum install -y unzip #安装unzip解压工具 [root@localhost ~]#unzip phpMyAdmin-4.0.10.20-all-languages.zip #解压 [root@localhost ~]#mv phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/phpmyadmin #复制phpMyAdmin文件到数据存放目录
在地浏览器的址栏中,输入http:// IP地址/phpmyadmin,访问phpMyAdmin返回页面如下图所示,说明phpMyAdmin安装成功。