小白零基础部署windows 2012 server前后台项目

springboot和vue两个前后端分离项目部署,前台使用的是nginx

首先后台打包部署

先双击clean,再package打包项目(由于是独立部署所以是jar包)
在这里插入图片描述打包成功,jar包在D盘路径下(synergy-0.0.1-SNAPSHOT.jar文件)
在这里插入图片描述在这里插入图片描述

部署到window sever 2012运行

登录EASY CONNECT连接远程桌面
在这里插入图片描述在这里插入图片描述
把本地的synergy-0.0.1-SNAPSHOT.jar包复制到服务器上

在这里插入图片描述使用cmd窗口( 路径一点要切换到jar包所在的文件夹路径)
使用命令 java - jar xxx (jar包的名称)
在这里插入图片描述后台部署成功

前台项目打包部署

打包vue项目
新建终端,输入命令 npm run build ,然后打包成功
在这里插入图片描述在这里插入图片描述在这里插入图片描述
注意事项:
在这里插入图片描述
1.服务器上没有这个就会少静态样式
publicPath: ‘…/…/’
assetsPublicPath: ‘/’,//开发使用

请添加图片描述请添加图片描述请添加图片描述

使用Nginx部署前台(这里使用的版本是1.2.2)
把dist文件夹放到nginx的文件夹里
在这里插入图片描述配置nginx,在conf文件夹下打开nginx.conf
在这里插入图片描述nginx.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;
client_max_body_size 8M;
client_body_buffer_size 128k;
fastcgi_intercept_errors on;
    #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       8080;  #替换为监听服务器的端口号
        server_name  127.0.0.1 #替换为监听服务器的ip地址
        #添加头部信息
        proxy_set_header Cookie $http_cookie;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
         #这里与vue开发环境下的配置代理一样
         #生产环境下的代理地址
        location ^~ /api/{ #xx
            proxy_pass http://127.0.0.1:8081/;
       }
        location ^~ /city/{ #xx
            proxy_pass http://127.0.0.1:9000/;
       }
        location / {
            root   dist;
            index  index.html index.htm;
        }

        
        #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;
        #}
    }


    # 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;
    #    }
    #}

}

最后双击nginx.exe即可运行
在这里插入图片描述
到此前后台项目部署成功!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值