一、使用系统安装

1、使用dnf或者yum(没有yum可以自行安装)查看提供的应用流有哪些版本

yum module list php

dnf module list php

以上任意一种都可以出现图中结果

2、启动、自启动、停止、重启nginx

systemctl start nginx、systemctl enable nginx、systemctl stop nginx、systemctl restart nginx

3、启动php

systemctl start php-fpm

4、开启80端口(http)

firewall-cmd --permanent --zone=public --add-service=http

5、开启443端口(https)

firewall-cmd --permanent --zone=public --add-service=https

6、开启3306端口(mysql)

firewall-cmd --zone=public --add-port=3306/tcp --permanent

7、重启防火墙

firewall-cmd --reload

二、自主安装mysql

1、在安装前需要先检查系统安装了哪些rpm -qa|grep -i (可以自己选项需要查询的安装软件包列如:php等)

rpm -qa|grep -i mysql

2、卸载使用yum -y remove(使用*号可以不用逐个删除)或者rm -rf,使用find / -name查询目录,以上命令可以扩展其他软件。

yum remove mysql-community-common-5.7.20-1.el7.x86_64

yum -y remove mysql-*

find / -name mysql

rm -rf /etc/my.cnf

3、官网下载选择自己系统的mysql→点击跳转(本文章使用centos 9 stream版本→点击跳转)

https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm

4、在下载安装前禁用系统的mysql模块yum module disable <name>,此命令可扩展其他模块。

yum module disable mysql

下载、安装

wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm

yum -y install mysql80-community-release-el9-1.noarch.rpm

安装mysql服务

yum install -y mysql-community-server

启动mysql,启动后查看mysql状态

systemctl start mysqld

systemctl status mysqld

设置开启自启动并重载模块

systemctl enable mysqld
systemctl daemon-reload

5、查看mysql初始密码

vi /var/log/mysqld.log

6、登录mysql并修改密码,否则数据库会一直报错。

mysql -uroot -p
password:(此处输入密码不显示,但可以使用复制粘贴)
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';(此处设置的密码必须是大写+小写+数字+)

7、修改密码、降低密码策略、开放端口、远程连接不再建议。

三、自主安装php

1、官网下载需要的版本(本文章下载的是php7.4,https://www.php.net/distributions/php-7.4.30.tar.gz)

wget https://www.php.net/distributions/php-7.4.30.tar.gz

《CentOS 8+版本安装LNMP环境和LAMP环境》有2条评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

请先登录后再评论

12 + 1 =