部署顺序,自己用的
下载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
- 安装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
- 安装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"
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);
}
- war包直接放到
tomcat webapp
下 - 修改api访问去掉项目名,修改/conf/server.xml
在<Engine><Host>下添加一个Context节点
<Engine name="Catalina" defaultHost="localhost"...>
...
<Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true">
<!--去掉 appBase="webapps" 中的 webapps,docBase 使用绝对路径,杜绝 tomcat 启动2次相同的项目-->
<Context path="" docBase="/usr/local/Cellar/tomcat/9.0.12/libexec/webapps/jurua-api" reloadable="true" />
...
</Host>
...
</Engine>
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;
}
# http://ip:8080/ 如果最有有个"/"那么就是转发到“http://ip:8080”上,如果没有“/” 那么久转发到“http://ip:8080/api”上
location /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;
# }
#}
}
网友评论