当前位置: 首页 > news >正文

若依部署项目到服务器

目录

一、环境配置

redis

nginx(宿主机|dokcer)

1.宿主机

2.docker

二、打包jar包

0.查看后端配置

1.打包后端

2.打包前端

三、启动

1.后端

2.前端

 四、以上部署常见命令/错误


一、环境配置

之前的课都配过,先看看自己配了没

 看看启动了啥  docker ps

redis

见上  redis启用过了

nginx(宿主机|dokcer)

1.宿主机

强制启动,查看是否启动成功,没有就是端口占用,关了就行

 如果有以下,则证明是docker里边的,要么见2,要么停了dokcer再1

2.docker

docker run -d --name nginx\-p 80:80 \--restart=always \-v /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \-v /opt/nginx/html/dist:/usr/share/nginx/html \nginx:1.25.0

二、打包jar包

0.查看后端配置

1.打包后端

打包之后的在这里👇

2.打包前端

三、启动

1.后端

 

切换到自己的jar包放置路径
java -jar ruoyi-admin.jar

 这样就启动成功后端了

 访问路径  公网地址:8080

2.前端

把打包好的dist复制到宿主机上,注意自己的路径

 更改这里边的conf

 主要更改地方和源码在👇


#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  82.157.170.39 localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   /opt/nginx/html/dist;try_files $uri $uri/ /index.html;index  index.html index.htm;}location /prod-api/ {proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://172.17.0.1: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   /opt/nginx/html/dist;}# 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;#    }#}}

 运行地址  公网地址  出来验证码就算对了

 四、以上部署常见命令/错误

#查看端口是否被占用
sudo netstat -tulnp | grep :80#查看进程是否启动
ps aux | grep nginx#进入容器内部
docker exec -it nginx /bin/bash#查看容器内nginx.conf文件内容
cat etc/nginx/nginx.conf#关于防火墙
systemctl start firewalld 开启防火墙systemctl restart firewalld 重启防火墙systemctl status firewalld 查看防火墙状态systemctl disable firewalld 开机自动不启动防火墙firewall-cmd --permanent --add-port=端口/tcp 设置防火墙放
行端口,此操作需要重启防火墙生效# 重新加载防火墙规则
firewall-cmd --reload# 详细查看放行端口
firewall-cmd --list-all

后端没什么大问题,主要是前端

如果有404 500  页面无法访问错误,就是nginx.conf配置有错,或者nginx启动有错

http://www.xdnf.cn/news/1151839.html

相关文章:

  • 深入排查:编译环境(JDK)与运行环境(JRE/JDK)不一致时的常见 Java 错误及解决方案
  • 【Linux】如何理解 “一切皆文件”
  • 黑马点评系列问题之p70postman报错“服务器异常”
  • LeetCode中等题--167.两数之和II-输入有序数组
  • Java File 类详解:从基础操作到实战应用,掌握文件与目录处理全貌
  • 我用Cursor,1周上线了一个虚拟资料流量主小程序技术选型
  • Node.js:EventEmitter、Buffer
  • PCB 混合介质叠层:材料特性匹配与性能提升的技术解析
  • 如何解决 ‘NoneType‘ object has no attribute ‘get‘问题
  • 【取消分仓-分布式锁】
  • OpenCV特征点提取算法orb、surf、sift对比
  • 【数据类型与变量】
  • 学习C++、QT---29(QT库中QT事件的介绍和用了几个案例来对事件怎么使用的讲解)
  • UniApp 优化实践:使用常量统一管理本地存储 Key,提升可维护性
  • 7.19 换根dp | vpp |滑窗
  • 网络包从客户端发出到服务端接收的过程
  • 关于prometheus的一些简单的理解和总结
  • 1Panel中的OpenResty使用alias
  • 【Java源码阅读系列56】深度解读Java Constructor 类源码
  • SSH 密钥
  • C++ :vector的模拟
  • Oracle RU19.28补丁发布,一键升级稳
  • Python爬虫实战:研究psd-tools库相关技术
  • web前端渡一大师课 02 浏览器渲染原理
  • RESTful API设计与实现指南
  • 锂电池充电芯片
  • 从丢包到恢复:TCP重传机制的底层逻辑全解
  • 基于单片机智能插座设计/智能开关
  • MyBatis动态SQL实战:告别硬编码,拥抱智能SQL生成
  • 大模型军备竞赛升级!Grok 4 携 “多智能体内生化” 破局,重构 AI 算力与 Agent 2.0 时代