本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2024-11(1)

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

发布于2024-11-02 12:43     阅读(1013)     评论(0)     点赞(4)     收藏(4)


打包后端‘

1,打开若依,点击右侧的Maven展开Maven管理,选择ruoyi>Lifecycle 先双击clean清除原本启动项目时生成的文件。然后点击package等待项目打包,切记要取消运行再打包

打包完成后会在ruoyi-admin>src>target里面看到.jar后缀的文件,就代表打包成功(可以把这个文件复制出来存放到其他地方,方便后面启动)

2,这个就是打包出来的文件

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

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

打开cmd

java -jar ruoyi-admin.jar

要保证端口没有被占用

前端使用

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访问页面

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. }

原文链接:https://blog.csdn.net/m0_61265297/article/details/142172879



所属网站分类: 技术文章 > 博客

作者:再拍我就焖面

链接:http://www.phpheidong.com/blog/article/554279/f8b342cf130ffab7b060/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)