打包部署若依(RuoYi)SpringBoot后端和Vue前端图文教程

打印 上一主题 下一主题

主题 1038|帖子 1038|积分 3114

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
打包后端‘
1,打开若依,点击右侧的Maven展开Maven管理,选择ruoyi>Lifecycle 先双击clean清除原本启动项目时天生的文件。然后点击package等候项目打包,牢记要取消运行再打包
打包完成后会在ruoyi-admin>src>target内里看到.jar后缀的文件,就代表打包乐成(可以把这个文件复制出来存放到其他地方,方便后面启动)
2,这个就是打包出来的文件

假如没乐成,可以试试点这两个再清除一下

3,新建一个文件夹,把这个包丢进去

打开cmd
  1. java -jar ruoyi-admin.jar
复制代码

要保证端口没有被占用
前端利用
  1. npm run build:prod
复制代码

打包出来的文件

nginx
1,

2,把前端的dist打包文件放进去

3,运行(1)

4,启动(2)

  1. 启动
  2. start nginx
  3. 重新启动
  4. nginx -s reload
  5. 关闭nginx
  6. nginx -s stop
  7. 强制关闭
  8. taskkill taskkill /f /t /im nginx.exe
复制代码
nginx设置

  1. listen 填前端要运行的端口, 你想用什么端口就用什么端口,不一定和开发时候的端口一样
  2. listen       8085;
  3. tip:nginx配置好,前端访问就要用配置好的这个端口访问
复制代码
  1. 这里要填你后端的端口
  2. proxy_pass http://127.0.0.1:8025/;
复制代码



nginx访问页面
  1. ip+ nginx配置的前端端口
复制代码




  1. #user  nobody;
  2. worker_processes  1;
  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;
  6. #pid        logs/nginx.pid;
  7. events {
  8.     worker_connections  1024;
  9. }
  10. http {
  11.     include       mime.types;
  12.     default_type  application/octet-stream;
  13.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  14.     #                  '$status $body_bytes_sent "$http_referer" '
  15.     #                  '"$http_user_agent" "$http_x_forwarded_for"';
  16.     #access_log  logs/access.log  main;
  17.     sendfile        on;
  18.     #tcp_nopush     on;
  19.     #keepalive_timeout  0;
  20.     keepalive_timeout  65;
  21.     #gzip  on;
  22.     server {
  23.         listen       8085;
  24.         server_name  localhost;
  25.         root html//dist;
  26.         # root C://nginx//nginx-1.26.1//html//dist;
  27.         #charset koi8-r;
  28.         #access_log  logs/host.access.log  main;
  29.         location /{
  30.                         try_files $uri $uri/ /index.html;
  31.             index  index.html index.htm;
  32.                         autoindex on;
  33.         }
  34.         location /prod-api/{
  35.                         proxy_set_header Host $http_host;
  36.                         proxy_set_header X-Real-IP $remote_addr;
  37.                         proxy_set_header REMOTE-HOST $remote_addr;
  38.                         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  39.                         proxy_pass http://127.0.0.1:8025/;
  40.                 }
  41.         #error_page  404              /404.html;
  42.         # redirect server error pages to the static page /50x.html
  43.         #
  44.         error_page   500 502 503 504  /50x.html;
  45.         location = /50x.html {
  46.             root   html;
  47.         }
  48.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  49.         #
  50.         #location ~ \.php$ {
  51.         #    proxy_pass   http://127.0.0.1;
  52.         #}
  53.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  54.         #
  55.         #location ~ \.php$ {
  56.         #    root           html;
  57.         #    fastcgi_pass   127.0.0.1:9000;
  58.         #    fastcgi_index  index.php;
  59.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  60.         #    include        fastcgi_params;
  61.         #}
  62.         # deny access to .htaccess files, if Apache's document root
  63.         # concurs with nginx's one
  64.         #
  65.         #location ~ /\.ht {
  66.         #    deny  all;
  67.         #}
  68.     }
  69.     # another virtual host using mix of IP-, name-, and port-based configuration
  70.     #
  71.     #server {
  72.     #    listen       8000;
  73.     #    listen       somename:8080;
  74.     #    server_name  somename  alias  another.alias;
  75.     #    location / {
  76.     #        root   html;
  77.     #        index  index.html index.htm;
  78.     #    }
  79.     #}
  80.     # HTTPS server
  81.     #
  82.     #server {
  83.     #    listen       443 ssl;
  84.     #    server_name  localhost;
  85.     #    ssl_certificate      cert.pem;
  86.     #    ssl_certificate_key  cert.key;
  87.     #    ssl_session_cache    shared:SSL:1m;
  88.     #    ssl_session_timeout  5m;
  89.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  90.     #    ssl_prefer_server_ciphers  on;
  91.     #    location / {
  92.     #        root   html;
  93.     #        index  index.html index.htm;
  94.     #    }
  95.     #}
  96. }
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

卖不甜枣

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表