目錄
一、環境配置
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啟動有錯