阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ]

一.MySql5.7安装(yum)

1.下载YUM源rpm安装包

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2. 安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm

 3.安装Mysql 

yum install mysql-community-server

4.启动Mysql服务

systemctl start mysqld

5.设置开机启动

systemctl enable mysqld
systemctl daemon-reload

6.获取默认密码 

grep 'temporary password' /var/log/mysqld.log

7.设置新密码,默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误

set password for 'root'@'localhost'=password('MyNewPass2!');

8. 也可以设置密码策略为low

set global validate_password_policy=LOW;

9.设置可远程登录,%代表所有

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'MyNewPass2!' WITH GRANT OPTION;

10.配置默认编码为utf-8   

    vim /etc/my.cnf #进入配置,按 "i" 进入编辑模式,添加如下内容,然后按 "ESC"退出编辑模式, 输入":wq"保存

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

11.重新启动Mysql服务

systemctl restart mysqld

12.查看字符编码已是utf-8

show variables like 'character%';

 阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ]_第1张图片

13.配置文件路径

配置文件:/etc/my.cnf  
日志文件:/var/log//var/log/mysqld.log  
服务启动脚本:/usr/lib/systemd/system/mysqld.service  
socket文件:/var/run/mysqld/mysqld.pid

注意阿里云需要配置安全组开放3306端口

一.JDK1.8安装(yum)

1.检查是否已安装java

yum list installed | grep java

2.卸载掉

yum -y remove java-1.6.0-openjdk*
yum -y remove tzdata-java.noarch

3.查看软件包列表

yum search java | grep -i --color jdk

 阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ]_第2张图片

4.选择版本安装 

yum install -y java-1.8.0-openjdk*

 5.查看安装的版本

java -version

6.配置环境变量,JDK默认安装路径/usr/lib/jvm

①列出文件夹列表  ls /usr/lib/jvm

阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ]_第3张图片

②进入 vim /etc/profile 增加环境配置


# set java environment  
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
PATH=$PATH:$JAVA_HOME/bin  
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  
export JAVA_HOME  CLASSPATH  PATH 

 ③重新加载配置文件

source  /etc/profile

 ④查看环境变量是否配置成功

 echo $JAVA_HOME
 echo $PATH
 echo $CLASSPATH

 

三.安装Nginx

1.添加nginx源

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

 2.安装nginx

yum install -y nginx

 3.启动nginx  

systemctl start nginx.service

 4.设置开机启动

systemctl enable nginx.service

 5.ngxin的默认路径

(1) Nginx配置路径:/etc/nginx/
(2) PID目录:/var/run/nginx.pid
(3) 错误日志:/var/log/nginx/error.log
(4) 访问日志:/var/log/nginx/access.log
(5) 默认站点目录:/usr/share/nginx/html

6.重新加载nginx配置命令

nginx -s reload

 7.停止服务

nginx -s stop

8.项目配置示例 

#管理后台地址
server {
        listen       80;
        server_name  admin.xxx.com;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
            root  /home/xxx/xxx-admin/;
            index index.html
           # proxy_pass http://127.0.0.1:9001;
            proxy_connect_timeout 600;
            proxy_read_timeout 600;
        }
    }

#单项目spring-boot地址
server {
        listen       80;
        server_name  api.xxx.com;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_connect_timeout 600;
            proxy_read_timeout 600;
        }



         #SSL证书配置
        #ssl on;#启用ssl功能
        listen 443 ssl;
        ssl_certificate cert/cert_2574000_api.xxx.com.pem;#证书文件
        ssl_certificate_key cert/cert_2574000_api.xxx.com.key;#私钥文件
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
        ssl_prefer_server_ciphers on;
    }

 四.安装Redis

1.安装redis

yum install redis

2.下载fedora的epel仓库 

 

yum install epel-release

3. Redis常规命令

# 启动redis
systemctl start redis.service
# 停止redis
systemctl stop redis.service
# 查看redis运行状态
systemctl status redis.service
# 重启redis
systemctl restart redis.service
# 查看redis进程
ps -ef | grep redis

4.设置开机启动 

systemctl enable redis.service

5.进入配置文件设置密码等

  vim /etc/redis.conf

1.解放其他ip可访问: 
  bind 127.0.0.1     →→→  #bind 127.0.0.1
2.取消保护模式,可以给redis desktop manager访问: 
  protected-mode yes →→→  protected-mode no
3.后台运行: 
  daemonize no     →→→  daemonize yes
4.修改密码: 
  # requirepass foobared  →→→ requirepass 123456

6.重启Redis

systemctl restart redis.service

7.使用密码登录Redis

阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ]_第4张图片

你可能感兴趣的:(阿里云CentOs7.5安装 [ Mysql5.7 ] [ JDK1.8 ] [ Nginx ] [ Redis ])