springboot + vue + nginx+ MS SQL Server项目部署方法

一、nginx

1.1 安装

自行搜索nginx进入官网nginx: download选择相应的版本即可。

直接解压到自定义目录:

双击运行nginx.exe,出现终端一闪而过,浏览器输入localhost,如下,说明安装启动成功:

1.2 配置


#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       8081;  # Vue 端口(页面)
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location /api {
            proxy_pass http://localhost:8080/;

                # springboot 端口
        }


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

}
 

当然,上边的api是因为vue里边所有接口请求路径是写成以api开头,配置时,根据自己请求路径前缀而定 

1.3 运行

重新双击nginx.exe,可以运行,也可以在cmd终端运行

关闭nginx:

nginx -s quit :完整有序的停止nginx

启动nginx    start nginx

重启服务: service nginx restart

快速停止或关闭Nginx:nginx -s stop

正常停止或关闭Nginx:nginx -s quit

配置文件修改重装载命令:nginx -s reload

二、Vue打包

2.1 打包

npm run build

2.2 安装

 打包得到dist包,将里边的static目录和index.html文件复制到nginx的html目录下(可以将html目录中自带的文件删除):

重新双击nginx.exe,浏览器输入localhost:

注意:更新时需要删除原来的,不要直接粘贴,因为打包里面文件名称是随机的。

2.3 静态资源与相对路径

1、打开 build/utils.js 文件,在如下位置添加 publicPath: '../../';

2、将config.js文件下index.js中的assersPublishPath,改为‘./’,

 build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

三、JDK

直接在网上搜素下载直接安装版本就可以

Java Downloads | Oracle

四、SpringBoot 打包

参见:1、Springboot如何打包部署项目_程序三两行-CSDN博客_springboot打包

2、在IntelliJ IDEA中打包SpringBoot项目_IAN_JIANG的博客-CSDN博客_ij打包springboot

4.1、pom.xml

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.1.0</version>
    </plugin>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
</plugins>

build下需要有的插件

注意:如果Mybatis generator代码生成插件,需要注释掉

4.2 打包

Maven中选择package双击

4.3 测试

java -jar erpcloud-0.0.1-SNAPSHOT.jar

五、MS SQL Server Express

5.1 MS SQL Server Express 安装

1、网上搜索安装 SQLExpress 2008 R2(win 7支持,高版本win7不支持)

2、下载安装管理器

 

 3、添加备份的数据库

5.2 MS SQL Server设置

参见:SQLServerException:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败(转)_yssa1125001的博客-CSDN博客

SQL Server 配置管理器

在这里插入图片描述

1、如果Named Pipes 未启用,则右键→启用 

2、使用telnet命令测试1433端口是否打开。首先要保证telnet服务开启。开启win7 telnet的方法在这里:http://blog.163.com/jackie_howe/blog/static/199491347201251723939691/

开始菜单 → 运行cmd → 输入:telnet 127.0.0.1 1433,(注意telnet与127之间有空格,1与1433之间有空格)。

错误提示:

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接_野猪佩奇ii的博客-CSDN博客

这个问题其实最主要还得看后面那一句话【The server selected protocol version TLS10 is not accepted by client preferences [TLS12]】,意思是数据库服务端的协议版本是TLS10,而客户端协议版本是TLS12。 
只需要在你的设备上找到jdk的安装目录【\Java\jdk1.8.0_291\jre\lib\security】下的java.security改改安全协议的配置即可。删掉这两个:TLSv1、TLSv1.1。特别要注意的是,如果你是选择了jre的运行环境来运行,那就是这个目录【\jre1.8.0_291\lib】。 

我的jdk是1.7,所以java.security在conf目录下,搜索可以找到。
修改前:  

在这里插入图片描述
修改后:  

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值