Deploy the ruoyi front-end and back-end projects to the linux service
1. Modify the root directory of vue
In the ruoyi-ui/build/index/index.js file
Change publicPath topublicPath=’…/…/’
2. Modify the ruoyi-vue.config.js file
1. Modify the port number
const port = process.env.port || process.env.npm_config_port || 8083 // 端口号
2. Modify the back-end server address
proxy:{
target:XXXX}
3. Configure nginx.conf
server {
listen 80;//前端端口号
server_name localhost;//前端名
location / {
root /home/ruoyi/projects/ruoyi-ui;//前端文件目录
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
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 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
4. Set the jar package to run all the time
1. Create a new txt file in the project folder and choose any name
2. Run the command
nohup java -jar xxx.jar >./temp.txt 2>&1 &