小强

导航

类似问卷星的开源项目Tduck填鸭部署到Linux服务器

 1.去gitee上把前后端代码下载到本地。

后端源码:https://gitee.com/TDuckApp/tduck-platform
前端源码:https://gitee.com/TDuckApp/tduck-front

2.使用idea打开tduck-platform后端代码,双击package打包生成tduck-api.jar包。

 3.使用WinSCP把jar包放到服务器指定目录/home/software/tduck-platform

 4.使用java命令运行springboot项目

nohup java -Dfile.encoding=UTF-8 -jar tduck-api.jar & --后台运行
java -jar /home/software/tduck-platform/tduck-api.jar --测试用的

5.前端项目打包

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install 
cnpm run build

6.使用WinSCP把项目放到服务器的nginx下面,并解压缩

cd /usr/local/nginx/html
unzip -o tduck.zip -d /usr/local/nginx/html

7.修改nginx配置文件,启动nginx

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

       location / {
          # 静态文件地址
            root   /usr/local/nginx/html/tduck;
	    try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
		
	location /tduck-api/{
	    proxy_set_header Host $http_host;
	    proxy_set_header X-Real-IP $remote_addr;
	    proxy_set_header REMOTE-HOST $remote_addr;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	    # 改为你后端接口地址   http://xxxx/tduck-api/
	    proxy_pass http://localhost:8999/tduck-api/;
	}

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
systemctl start nginx --启动   
systemctl stop nginx --关闭
ps -ef|grep tduck-api.jar --获取进程号
kill 进程号

posted on 2022-03-01 20:55  搬砖狗-小强  阅读(549)  评论(0编辑  收藏  举报