部署 VPS

部署顺序,自己用的

  1. 安装mysql
  2. 安装man命令 yum install man man-pages
  3. 安装jdk8
下载jdk
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.rpm
安装jdk
yum localinstall jdk-8u172-linux-x64.rpm
  1. 安装tomcat8
wget http://ftp.riken.jp/net/apache/tomcat/tomcat-8/v8.0.52/bin/apache-tomcat-8.0.52.tar.gz
tar zxvf apache-tomcat-8.0.52.tar.gz 
 mv apache-tomcat-8.0.52 /usr/tomcat8
cd /usr/tomcat8/

./bin/startup.sh
  1. 安装redis
$ wget http://download.redis.io/releases/redis-4.0.9.tar.gz
$ tar xzf redis-4.0.9.tar.gz
$ cd redis-4.0.9
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/redis-4.0.9/src'
make: *** [all] Error 2
$ yum grouplist
$ yum groupinstall 'Development Tools'
$ yum install jemalloc-devel
$ cd redis-4.0.9
$ make
$ src/redis-server
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
  1. 使用gradle打war包
apply plugin: 'war'
war.archiveName "jurua-api.war"
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

继承 SpringBootServletInitializer类并且重写** configure**方法

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(JuruaApiApplication.class);
}
  1. war包直接放到tomcat webapps
  2. 修改api访问去掉项目名,修改/conf/server.xml
下添加一个Context节点

  
...  
      
      
      

...  
      
...  
 
  1. dist文件夹和index.html放到jurua-api下面。不行就看这个和这个
  2. 或者配置nginx

nginx安装, 简单配置文件如下:

worker_processes  auto;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    gzip on;
    gzip_proxied any;
    #gzip_min_length 1000;
    gzip_comp_level 4;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;

    upstream my_api {                                                         
        server ip:8080;                                                
        keepalive 2000;
    }

    server {
        listen       80;
        server_name  www.*.cn;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location  / {
            proxy_pass   http://localhost:9000;
        }
      
        location /api/ { 
            # http://ip:8000/ 如果有http://ip:8000"/",那么就是转发到“http://ip:8000”上,如果没有“/”,像这样 "http://ip:8000"。那么就会转发到“http://ip:8000/api”上
            proxy_pass   http://localhost:8080/;
        }
    }

    server {
        listen       9000;
        server_name  localhost;

        location / {
            #root   /Users/to/www;
            root   /usr/local/to/www;
            index  index.html;
        }
    }

    #server {
    #    listen       80;
    #    server_name  api.*.cn;
    #
    #    location  / {
    #        proxy_pass   http://localhost:8080;
    #    }
    #}

}

你可能感兴趣的:(部署 VPS)