1.VUE前台配置以及打包部署
(1)Vue前台配置
①配置nginx,在nginx\conf\nginx.conf文件中,配置以下三点:
server {
listen 80;
server_name localhost;
location / {
#①root存放前端项目的目录地址,即nginx/html目录
root /project/ruoyi/dist/;
try_files $uri $uri/ /index.html;
#②index配置首页文件
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/prod-api/; #③后台地址以及端口号
proxy_connect_timeout 60s;
proxy_read_timeout 300s;
proxy_send_timeout 60s;
}
②在nginx 目录下输入命令启动nginx:start nginx,在网页上访问 http://localhost:8080。
(2)Vue前台打包部署
①在前端项目路径下输入npm run build:prod
注:build:prod的来源
②命令执行结束后,将dist目录下全部文件nginx\html 下(注:需要覆盖掉nginx\html 下的index.html)
③在网页上访问 http://localhost:8080,如果能访问到系统首页则前台部署结束。
2.Springboot+ Vue-element-admin后台配置以及打包部署
(1)本地部署
①后台application.yml配置文件中,添加context-path:/prod-api(注:prod-api与nginx配置文件后台地址路径一致)
②后台打包生成jar文件,在jar目录下执行命令java -jar ruoyi-admin.jar
③最后测试
(2)linux服务器上部署
①后台配置文件以及打包生成jar包与本地部署一致
②安装putty工具 https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
③在Putty工具中进入linux服务中,输入linux服务ip以及用户名,密码
④ps -ef|grep java 查看当前linux服务java进程
⑤kill -9 进程号 杀死进程
⑥service nginx stop 关闭nginx服务,此命令可执行也可不执行
⑦进入到jar包文件路径下
⑧nohup java -jar -Xms2048M ruoyi-admin.jar & 执行jar文件
⑨service nginx start 启动nginx服务,此命令如果在前面执行stop的话,就必须执行start