1.安装mysql8.0
官方文档:
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
下载rpm
yum localinstall http://mirrors.ustc.edu.cn/mysql-repo/mysql80-community-release-el7-3.noarch.rpm (现在很慢,用下面这个链接里面介绍的方法)
https://blog.csdn.net/Yuan_xii/article/details/105539908
安装rpm
yum install mysql-community-server
启动mysql服务端
service mysqld start
查找初始密码
一定要先启动mysqld服务,不然不会生成初始密码:
sudo grep 'temporary password' /var/log/mysqld.log
设置新密码,否则不让登录
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'MyNewPass4!ysp123456';
5.7以后可能报错:
ALTER USER USER() IDENTIFIED BY ‘MyNewPass4!ysp123456’;
增加用户,赋予权限
# 注意mysql_native_password 加密方式,否则使用phpmyadmin会碰到问题 https://blog.csdn.net/zhezhebie/article/details/106289214
# 以前一步执行的创建用户分配权限,现在分为两步
create user 'ysp'@'%' identified WITH mysql_native_password by 'Ysp123456!';
grant all privileges on *.* to ysp@'%';
flush privileges;
其他镜像源:
http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-8.0-community/el/7/x86_64/
2.安装nginx:
yum localinstall http://mirrors.ustc.edu.cn/nginx/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm
查看nginx版本
nginx -v
3.安装php:
安装yum源
yum install epel-release
安装php源
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
安装php拓展
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json
php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo
php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-soap php73-php-pecl-zip
php73-php-process php73-php-pecl-yaf php73-php-xml php73-php-pecl-swoole4
设置开机启动
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
查看php版本
php73 -v
举个例子,你要安装其他拓展,例如看看有没有swoole的拓展:
yum search swoole #找到了下面这个拓展,那么就可以直接安装了
yum install -y php73-php-pecl-swoole4.x86_64
php73 -m |grep swoole
cp /usr/bin/php73 /usr/bin/php #后续就可以直接使用php -m
可以看到swoole已经被安装好了。
4.安装redis最新版本:
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum --enablerepo=remi install redis -y
systemctl start redis
设置服务开机启动
systemctl enable mysqld
systemctl start mysqld
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
systemctl enable nginx
systemctl enable redis
5.查看已经开机启动的服务:
systemctl list-unit-files |grep enabled
=2020-05-27 补充=
安装postgresql:
https://www.postgresql.org/download/linux/redhat/
使用国内清华镜像:
速度更快,因为之前看清华的镜像太多了,不知道要安装哪一个,所以先安装了官方的源。
yum localinstall http://mirrors.ustc.edu.cn/postgresql/repos/yum/12/redhat/rhel-7.8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql12 postgresql12-server -y
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
默认用户postgres,无密码,相当于mysql的root用户
psql postgres
\passowrd postgres #接着输入两次密码
http://mirrors.ustc.edu.cn/postgresql/repos/yum/12/redhat/rhel-7.8-x86_64/
==== 2021-02-04===
yum直接localinstall rpm包速度变得巨慢(10kb/s),直接下载集合包很快(3M/s).
最新的集合包:
http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar