将springboot项目部署到linux 服务器

1.pom.xml 配置版本号 名字

<groupId>com.yixiatech</groupId>

<artifactId>manghe</artifactId>

<version>1.0.6-manghe</version>

2.application.properties中配置mysql,redis,项目端口号,项目前置url

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.datasource.url=jdbc:mysql://localhost:3306/manghe?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8&autoReconnect=true

spring.datasource.username=root

spring.datasource.password=aaaaaaaa

mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

mybatis.configuration.map-underscore-to-camel-case=true

spring.redis.host=localhost

spring.redis.port=6379

spring.redis.password=aaaaaaaa

server.servlet.context-path=/api

server.port=9999

3.linux服务器需要安装的必备软件

jdk 11

mysql 注意版本号 跟数据库连接池的版本号对上

redis 记得设置密码,配置文件在/etc/redis.conf,

requirepass 自己的密码

nginx服务器 配置文件在 /etc/nginx/nginx.config

主要配置如下,配置了https以及转发了springboot的端口

server {

     #HTTPS的默认访问端口443。     #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。     listen 443 ssl;


     #填写证书绑定的域名     server_name yixiatech.com;


     #填写证书文件绝对路径     ssl_certificate /etc/nginx/ssl/yixiatech.com.pem;

     #填写证书私钥文件绝对路径     ssl_certificate_key /etc/nginx/ssl/yixiatech.com.key;


     ssl_session_cache shared:SSL:1m;

     ssl_session_timeout 5m;

     #自定义设置使用的TLS协议的类型以及加密套件(以下为配置示例,请您自行评估是否需要配置)     #TLS协议版本越高,HTTPS通信的安全性越高,但是相较于低版本TLS协议,高版本TLS协议对浏览器的兼容性较差。     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

     ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

     #表示优先使用服务端加密套件。默认开启     ssl_prefer_server_ciphers on;


    location / {

     root  /usr/share/nginx/html;

     index index.html;    }      

 location /api {

        proxy_pass http://localhost:9999;

        proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

    }

}

server {

    listen 80;

    #填写证书绑定的域名    server_name yixiatech.com;

    #将所有HTTP请求通过rewrite指令重定向到HTTPS。    rewrite ^(.*)$ https://$host$1;

    location / {

        root  /usr/share/nginx/html;

     index index.html;

    }

}

}

4.自己电脑安装数据库控制台 navicat,服务器控制台 finalshell

5.阿里云ecs服务器控制台的安全组打开 springboot,mysql,nginx的端口号

6.常用命令

查看运行的java进程:ps -ef | grep java

杀死进程:kill xxx

重启命令: sudo systemctl restart xxx

重启nginx: sudo systemctl restart nginx

启动nginx: sudo systemctl start nginx

停止nginx: sudo systemctl stop nginx

运行jar包:java -jar xxx.jar

后台启动jar包:nohup java -jar manghe-1.0.1-manghe.jar &> manghe.log &

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容