1.打包前端Vue文件,在项目的Bin文件夹中有个build.bat 点击运行

2.将生成的dist文件夹移动到长途工具上,自选一个你可以记住的位置。我用的是mobieXterm
3.打开edit侧边栏的maven,你要将ruoyi-admin打包,但是你直接打包可能会显示错误,找不到依赖,点击父目录ruoyi中的install,要先下载依赖,再点击ruoyi-admin中的打包,即可成功。打包后的jar文件存在了项目下的target下。

4.然后拖入到长途连接你指定的文件夹中。
5.配置文件,application-druid.yml 配置你的数据库为你的云服务器上的数据库。

将localhost 换成你的云服务ip地点
6.进入阿里云服务器安全组,设置开放端标语(你的若依端标语)
7.防火墙端口开启(我是把防火墙整个全关了,很不安全,以是可以设置一下)
8.进入文件夹中输入下令 java -jar +打包的文件名(此时应该看到网页显示你的后端启动)
9.输入nohup java -jar +文件名 这个是挂起的操纵,不消开云服务器也能跑。
10.启动下好的nginx
11.配置nginx(最难的一步)
- #user root;
- 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;
- proxy_connect_timeout 300;
- proxy_send_timeout 300;
- proxy_read_timeout 300;
- #gzip on;
- server {
- listen 80;
- server_name 8.130.67.151;#(你的服务器地址)
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root /usr/local/project/dist;#(你的dist文件地址)
- index index.html index.htm;
- try_files $uri $uri/ /index.html;
- }
- location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {#(处理静态资源)
- root /usr/local/project/dist; # Vue 项目打包后的 dist 目录路径
- expires 30d;
- }
- #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;
- #}
- location /prod-api/ {# 在网页上F12会发现有这个,请求地址的代理配置,所以一定要加上
- proxy_pass http://localhost:8082/; # 替换成前端vite.config.js中targetI地址:后端应用的端口.(设置成云服务器的IP地址,就会有验证码出不来的问题)
复制代码
- # 设置请求头,以保留访问客户端的真实IP地址
- proxy_set_header Host $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;
- add_header 'access-control-allow-origin' '*';
- add_header 'access-control-allow-credentials' 'true';
- add_header 'access-control-allow-methods' '*';
- }
- }
- # 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;
- # }
- #}
- }
复制代码
记住配置完肯定要革新一次。
下面是阿里云安全组配置。
这下就应该差不多喽
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |