服务器安装环境
nginx
下载依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
创建存放位置
cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
解压
tar -xvf nginx-1.13.7.tar.gz
//进入nginx目录
cd /usr/local/nginx
//进入目录
cd nginx-1.13.7
//执行命令 考虑到后续安装ssl证书 添加两个模块
./configure --with-http_stub_status_module --with-http_ssl_module
//执行make命令
make
//执行make install命令
make install
启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
部署https服务 ssl证书
将下载的key文件和pem文件放到conf/cert下
#以下属性中,以ssl开头的属性表示与证书配置有关。
server {
#配置HTTPS的默认访问端口为443。
#如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
#如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
listen 443 ssl;
#填写证书绑定的域名
server_name scgdzhfw.com;
root html;
index index.html index.htm;
#填写证书文件名称
ssl_certificate cert/9608060_www.scgdzhfw.com.pem;
#填写证书私钥文件名称
ssl_certificate_key cert/9608060_www.scgdzhfw.com.key;
ssl_session_timeout 5m;
#表示使用的加密套件的类型
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
#Web网站程序存放目录
root html;
index index.html index.htm;
}
}
server {
listen 80;
#填写证书绑定的域名
server_name scgdzhfw.com;
#将所有HTTP请求通过rewrite指令重定向到HTTPS。
rewrite ^(.*)$ https://$host$1;
location / {
index index.html index.htm;
}
}
jdk
下载jdk tar.gz格式的
https://www.oracle.com/java/technologies/downloads/
解压
tar -zxvf jdk-17_linux-x64_bin.tar.gz
设置环境变量
vim /etc/profile
结尾追加
export JAVA_HOME=/usr/local/java/jdk-17.0.6
export PATH=$PATH:$JAVA_HOME/bin
重新加载环境变量
source /etc/profile
mysql
下载
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.31-1.el9.x86_64.rpm-bundle.tar
https://downloads.mysql.com/archives/community/
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vsyPCFPU-1680445913697)(C:\Users\微微一笑\AppData\Roaming\Typora\typora-user-images\image-20230402195122331.png)]
解压
tar -xvf mysql-8.0.31-1.el9.x86_64.rpm-bundle.tar
运行顺序为
rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm
初始化
mysqld --initialize --console
临时密码
x(E9XJXF6a*s
设置用户组
chown -R mysql:mysql /usr/local/mysql/
启动mysql
systemctl start mysqld
修改密码
alter user 'root'@'localhost' identified by '123456';
开启远程连接
use mysql;
update user set host='%' where user='root';
Grant all privileges on root.* to 'root'@'%'; #执行两次
alter user root identified with mysql_native_password by '123456';
FLUSH PRIVILEGES;
show variables like 'character%'; # 查看字符编码
查看所有用户
select user from mysql.user;
修改用户名
use mysql;
update user set user ='mysql' where user ='root';
刷新权限
flush privileges;
redis
下载
wget http://download.redis.io/releases/redis-6.2.0.tar.gz
解压
tar -zxvf redis-6.2.0.tar.gz
进入目录
cd redis-6.2.0
编译
make
make PREFIX=/usr/local/redis install
启动
./bin/redis-server& ./redis.conf
或者
redis-server /usr/local/redis/redis.conf
修改配置文件
启用守护进程
daemonize yes
端口
port 11111
外网连接
protected-mode yes
# 修改允许访问的IP为所有
bind 0.0.0.0 -::1
设置环境变量
vim /etc/profile
export PATH=$PATH:/usr/local/redis/bin
source /etc/profile