卖不甜枣 发表于 2024-11-18 10:10:48

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

打包后端‘
1,打开若依,点击右侧的Maven展开Maven管理,选择ruoyi>Lifecycle 先双击clean清除原本启动项目时天生的文件。然后点击package等候项目打包,牢记要取消运行再打包
https://i-blog.csdnimg.cn/direct/f3e6d9476fe0409aaa232f1c63e3dd4a.png打包完成后会在ruoyi-admin>src>target内里看到.jar后缀的文件,就代表打包乐成(可以把这个文件复制出来存放到其他地方,方便后面启动)
2,这个就是打包出来的文件
https://i-blog.csdnimg.cn/direct/e9d4356fd45440f3a03f4f78251fa8ba.png
假如没乐成,可以试试点这两个再清除一下
https://i-blog.csdnimg.cn/direct/5f01852ef5714301b31286c0f7d7c491.png
3,新建一个文件夹,把这个包丢进去
https://i-blog.csdnimg.cn/direct/99403fd07270492186b8811bcaa62b2f.png
打开cmd
java -jar ruoyi-admin.jar https://i-blog.csdnimg.cn/direct/747c83b330e747a7853fc8f6db6cdc8b.png
要保证端口没有被占用
前端利用
npm run build:prod https://i-blog.csdnimg.cn/direct/7a299747a9924e2ab09d35f13ca5848b.png
打包出来的文件
https://i-blog.csdnimg.cn/direct/6cfe0509c6384c20a160bfb3690275f8.png
nginx
1,https://i-blog.csdnimg.cn/direct/74a0fd42c0a0436682462d994f406f04.png
2,把前端的dist打包文件放进去https://i-blog.csdnimg.cn/direct/52feb14516c4449dbd43f024da0f6c6a.png
3,运行(1)
https://i-blog.csdnimg.cn/direct/29ef9118ef034fadabb22b5e29ec9a1f.png
4,启动(2)
https://i-blog.csdnimg.cn/direct/918578b21c0947e8a9f4465d841b36bd.png
启动

start nginx

重新启动

nginx -s reload

关闭nginx

nginx -s stop


强制关闭

taskkill taskkill /f /t /im nginx.exe nginx设置
https://i-blog.csdnimg.cn/direct/9b63334b47274fa4ad52c15daec31776.png
listen 填前端要运行的端口, 你想用什么端口就用什么端口,不一定和开发时候的端口一样

listen       8085;

tip:nginx配置好,前端访问就要用配置好的这个端口访问 这里要填你后端的端口
proxy_pass http://127.0.0.1:8025/; https://i-blog.csdnimg.cn/direct/fdd0fda9ba31459a98e50ece013ee0df.png
https://i-blog.csdnimg.cn/direct/16abeb279a6b47f39dba0c5e28af1018.png
https://i-blog.csdnimg.cn/direct/ebbcdd1b1b724fac8afb9179ddb0c077.png
nginx访问页面
ip+ nginx配置的前端端口 https://i-blog.csdnimg.cn/direct/087ee09149524a2bafe16437f099ac67.png




#usernobody;
worker_processes1;

#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;

#pid      logs/nginx.pid;


events {
    worker_connections1024;
}


http {
    include       mime.types;
    default_typeapplication/octet-stream;

    #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_loglogs/access.logmain;

    sendfile      on;
    #tcp_nopush   on;

    #keepalive_timeout0;
    keepalive_timeout65;

    #gzipon;

    server {
      listen       8085;
      server_namelocalhost;
      root html//dist;
      # root C://nginx//nginx-1.26.1//html//dist;
      #charset koi8-r;

      #access_loglogs/host.access.logmain;

      location /{
                        try_files $uri $uri/ /index.html;
            indexindex.html index.htm;
                        autoindex on;
      }

      location /prod-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;
                        proxy_pass http://127.0.0.1:8025/;
                }

      #error_page404            /404.html;

      # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504/50x.html;
      location = /50x.html {
            root   html;
      }

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ \.php$ {
      #    proxy_pass   http://127.0.0.1;
      #}

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      #location ~ \.php$ {
      #    root         html;
      #    fastcgi_pass   127.0.0.1:9000;
      #    fastcgi_indexindex.php;
      #    fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
      #    include      fastcgi_params;
      #}

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
      #    denyall;
      #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_namesomenamealiasanother.alias;

    #    location / {
    #      root   html;
    #      indexindex.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_namelocalhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_keycert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout5m;

    #    ssl_ciphersHIGH:!aNULL:!MD5;
    #    ssl_prefer_server_cipherson;

    #    location / {
    #      root   html;
    #      indexindex.html index.htm;
    #    }
    #}

}


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 打包部署若依(RuoYi)SpringBoot后端和Vue前端图文教程