若依管理系統 -- 部署到Linux


一、前言

  1、非常感謝若依作者為大家提供的非常優質的開源web項目,非常感謝!!!

  2、若依官方文檔:http://doc.ruoyi.vip/ruoyi/

  3、若依官方鏈接:

    1)若依管理系統官方體驗地址:http://vue.ruoyi.vip/login?redirect=%2Findex

    2)若依官網:http://www.ruoyi.vip/

    3)RuoYi源碼地址:https://gitee.com/y_project/RuoYi

    4)RuoYi-Vue(前后端分離版本)地址:https://gitee.com/y_project/RuoYi

 

 

二、部署前工作

  1、系統:阿里雲 centOs8

  2、安裝並配置好以下應用軟件

    1)jdk1.8 +

    

    2)maven

    

     3)MySQL

    

    4)nginx

    

     5)Redis

    

 

 

三、前端工程

  1、執行:npm install

  

    1)報錯:

    ReferenceError: primordials is not defined

    

    2)解決辦法:

      A:打開cmd: node -v 查看nodejs的版本

        這個必須要nodejs10+的版本,我是12.16版本就不行

        

      B:去官網下載nodejs10+的版本來安裝:https://nodejs.org/dist/latest-v10.x/

        

    3)報錯:

    

     4)解決:node-sass 的數據源沒設置 -->  npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass

      再重新  npm install  --> OK

      

  

  2、執行:npm install --registry=https://registry.npm.taobao.org

  

    

  3、修改配置文件中的兩個端口號

    1)nginx端口

     

     2)后端地址及端口(這個端口就是連接后端的,所以,這個端口要和后端工程application.yaml中的端口配置相同)

    

 

 

  4、執行:npm run build:prod

   

   

 

 

 四、后端工程

  1、修改數據庫地址、用戶名、密碼,配置文件的“文件位置”。

  2、修改端口號(這個端口號要和前端工程的端口號相一致)

  3、去后端工程的bin目錄下

  

 

   4、在Linux下新建一個目錄(我自己新建的   /usrl/local/web),專門用來裝前后端工程。把前后端工程上傳到Linux

  

 

  5、配置nginx的配置文件

    1)把里面的  server_name 改成自己的阿里雲IP地址

    2)再配置指向后端工程的反向代理

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

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

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  IP地址;  # 別寫localhost

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/local/web/dist;  # 前端工程的目錄
            index  index.html;  # 前端頁面
            try_files $uri $uri/ /index.html;
        }
        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://localhost:8080/;
        }
        #error_page  404              /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_index  index.php;
        #    fastcgi_param  SCRIPT_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 {
        #    deny  all;
        #}
    }


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

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


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

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

}

 

   6、用后台的方式啟動  后端工程:nohup java -jar ruoyi.jar > ruoyi_log.out &

  

 

 

 啟動完成,用瀏覽器打開網址就可以了。

 

 

 

 

 

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM