springboot项目部署以及Nginx配置
2018-07-04 本文已影响2909人
黄二狗V
主要内容
1.后台运行jar
2.nginx安装配置
将springboot项目打包成jar就不概述了。
- 后台运行jar,使用命令
nohup java -jar ....jar &
nohup java -jar ....jar >temp.text &
第一种,默认输出到nohup.out文件,第二种为指定输出文件。
- 查看端口占用情况,使用kill -9 进程id,可杀死进程。
netstat -nlp |grep :8080
- Nginx安装
需要先安装依赖
yum -y install gcc gcc-c++;
yum -y install pcre-devel zlib-devel openssl-devel
安装nginx
wget -P /usr/temp http://nginx.org/download/nginx-1.15.1.tar.gz
tar -zxvf nginx-1.15.1.tar.gz
cd nginx-1.15.1
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
启动nginx
cd /usr/local/nginx/sbin
./nginx -s reload
配置代理
vi /usr/nginx/conf/nginx.conf
添加如下内容 /api/ 根据你自己的情况定,IP也是
location /api/ {
proxy_pass http://0.0.0.0:8080;
}
如上,会转发到http://0.0.0.0:8080/api/