一、下载、更新依赖
1、更新系统版本至7.9
yum update
2、下载Vim
yum install vim -y
3、下载gcc(C语言环境,redis依赖它)
yum install gcc
软件统一安装在/usr/local/software目录下,源码统一解压缩在/usr/local/source
二、Java
参考:CSDN
1、下载java1.8_202压缩包
wget https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz
2、解压到指定目录
#创建安装路径 mkdir /usr/local/software/java/ #解压 tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/local/software/java
3、配置环境变量
#打开配置文件 vim /etc/profile
# 在末尾添加以下内容 export JAVA_HOME=/usr/local/software/java/jdk1.8.0_202 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
4、刷新配置及创建软连接
#刷新配置 source /etc/profile
#添加软连接 ln -s /usr/local/software/java/jdk1.8.0_202/bin/java /usr/bin/java
三、Redis
参考:安装Redis
1、下载redis5.0.14版本压缩包
wget http://download.redis.io/releases/redis-5.0.14.tar.gz
2、解压到指定目录
#创建安装路径 mkdir /usr/local/software/redis/
#创建源码路径 mkdir /usr/local/source/redis/
#解压
tar -zxvf redis-5.0.14.tar.gz -C /usr/local/source/redis
3、编译
#进入到解压完的目录内 cd /usr/local/source/redis/redis-5.0.14 #编译 make
4、安装
#安装到指定目录 make install PREFIX=/usr/local/software/redis
5、修改配置文件(远程访问、后台运行)
#从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录 cp /usr/local/source/redis/redis-5.0.14/redis.conf /usr/local/software/redis/bin/ #进入到安装目录内 cd /usr/local/software/redis/bin/ #编辑配置文件 vim redis.conf #1.找到bind 127.0.0.1并将其注释 #2.修改保护模式,不修改保护模式也是只能内网访问的 protected-mode no #3.daemonize no 改为yes 后台一直运行 daemonize yes #4.设置密码,这里建议设置密码 requirepass "你的密码"
6、开机自启动
(1)切换到/lib/systemd/system/目录,创建redis.service文件
cd /lib/systemd/system/ vim redis.service
(2)内容如下
[Unit] Description=redis-server After=network.target [Service] Type=forking # ExecStart需要按照实际情况修改成自己的地址 ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target
(3)启动开机自启
# 开机自动启动 systemctl enable redis # 启动redis服务 systemctl start redis # 查看服务状态 systemctl status redis # 停止服务 systemctl stop redis # 取消开机自动启动(卸载服务) systemctl disabled redis
四、Mysql
参考:CSDN
1、下载mysql
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
2、安装前准备
(1)卸载mariadb
#检查是否安装mariadb rpm -qa|grep mariadb #卸载 rpm -e --nodeps mariadb-libs #再次检查 rpm -qa|grep mariadb
(2)检查 libaio
#查看是否安装libaio rpm -qa|grep libaio #yum进行安装 yum -y install libaio
(3)检查 net-tools
#查看是否安装net-tools rpm -qa|grep net-tools #yum进行安装 yum -y install net-tools
(4)安装openssl-devel依赖
yum -y install openssl-devel
3、解压
#创建解压目录 mkdir /usr/local/source/mysql #解压 tar -xvf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar -C /usr/local/source/mysql/
4、安装
#进入解压目录 cd /usr/local/source/mysql/ #逐个安装 rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-libs-compat-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-devel-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm --nodeps --force rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm --nodeps --force
5、启动mysql
systemctl start mysqld #启动 systemctl restart mysqld #重启 systemctl status mysqld #查看状态 systemctl stop mysqld #关闭 systemctl enable mysqld #开机自启
6、查询初始密码
grep 'temporary password' /var/log/mysqld.log
7、修改密码
mysql -uroot -p #修改密码(大小写) ALTER USER 'root'@'localhost' identified by '121212'; #开启远程登陆 use mysql; update user set host='%' where user='root'; #刷新配置 flush privileges;
mysql配置文件目录: vim /etc/my.cnf
五、Nginx
参考:CSDN
1、下载
wget https://nginx.org/download/nginx-1.21.6.tar.gz
2、解压
#创建解压目录 mkdir /usr/local/source/nginx #解压 tar xvf nginx-1.21.6.tar.gz -C /usr/local/source/nginx/
3、配置【在解压目录内完成】
cd /usr/local/source/nginx/nginx-1.21.6/ #创建安装目录 mkdir /usr/local/software/nginx #配置安装参数 ./configure --prefix=/usr/local/software/nginx --with-http_stub_status_module --with-http_ssl_module
4、编译和安装【在解压目录内完成】
#编译 make #安装 make install
5、开机自启
(1)进入到/lib/systemd/system/目录
cd /lib/systemd/system/
(2)创建nginx.service文件,并编辑
vim nginx.service
(3)内容如下
[Unit] Description=nginx service After=network.target [Service] Type=forking ExecStart=/usr/local/software/nginx/sbin/nginx ExecReload=/usr/local/software/nginx/sbin/nginx -s reload ExecStop=/usr/local/software/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
(4)命令
systemctl daemon-reload #开机自启 systemctl enable nginx #启动 systemctl start nginx #查看已经启动的服务 systemctl list-units --type=service
标签:--,rpm,redis,CentOS7,usr,mysql,服务器,local,搭建 From: https://www.cnblogs.com/liuyu666/p/18283989