1、安装版本说明 php7.2+apache2.4+mysql5.7+redis

yum源:php升级

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

常用命令:yum list php* yum list installed | grep php* php --versi

2、安装php及扩展包

yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml  php-redis

php版本:PHP 7.2.27 (cli) (built: Jan 26 2020 15:49:49) ( NTS ) Copyright
© 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright ©
1998-2018 Zend Technologies
with Zend OPcache v7.2.27, Copyright © 1999-2018, by Zend Technologies

3、安装apache

yum -y install httpd
systemctl start httpd
lsof -i:80
systemctl enable httpd
httpd -v

Server version: Apache/2.4.6 (CentOS) Server built: Apr 2 2020
13:13:23

4、安装mariadb(备选)

yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
lsof -i:3306
mysql_secure_installation 
mysql -uroot -p
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
update user set password=password("123456") where user="root";
flush privileges;

5、安装mysql5.7

默认直接下载的是mysql5.5,需要更新mysql源。

1、下载mysql源安装包
 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2、安装mysql源
 yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
3、以上完成后,接下来就是检测源是否安装成功
 yum repolist enabled | grep "mysql.*-community.*"  

备注:可以通过 vim /etc/yum.repos.d/mysql-community.repo
修改这个配置用来yum的时候安装mysql的版本。5.7的enabled=1,其他度为0,就安装的是5.7的版本。

4、下载安装mysql数据库
yum -y install mysql-community-server    
systemctl start mysqld
systemctl status mysqld 
systemctl enable mysqld
systemctl daemon-reload               //重载服务
5、mysql5.7安装时会产生一个默认的密码,查看此密码的文件一般存在于/var/log/mysqld.log上
	grep 'temporary password' /var/log/mysqld.log         //查看密码

实际操作中未发现密码,更改vim /etc/my.cnf,添加skip-grant-tables 重启数据库,mysql登录。

6、更改数据库登陆密码
use mysql;
update user set authentication_string=password("123456") where user="root";
flush privileges;
7、升级数据结构,授权远程登陆。
mysql_upgrade -uroot -p123456     
mysql -uroot -p123456
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
vim /etc/my.cnf
#skip-grant-tables

6、安装redis

yum -y install redis
systemctl start redis
systemctl status redis
systemctl enable redis
ps -ef | grep redis
vim /etc/redis.conf   (开启远程,设置密码)
 61 #bind 127.0.0.1
 80 protected-mode no
 481 requirepass 654321     redis密码
ps -ef | grep redis
kill -9 PID
systemctl restart redis
进入redis: redis-cli -h 127.0.0.1 -p 6379
输入用户名、密码:auth  654321     info看信息
Logo

欢迎加入西安开发者社区!我们致力于为西安地区的开发者提供学习、合作和成长的机会。参与我们的活动,与专家分享最新技术趋势,解决挑战,探索创新。加入我们,共同打造技术社区!

更多推荐