一、将下载的nginx包放到 /home/soft下
二、解压下载的nginx包
tar -zxvf nginx-1.20.1.tar.gz
三、安装nginx
# 1.进入安装包目录
cd nginx-1.20.1
# 2.按顺序执行以下命令,安装nginx
./configure ;--preifx=/opt/nginx1.20
make
make install
四、将nginx添加为系统执行程序
ln -s /opt/nginx1.20/sbin/nginx /usr/bin/nginx
五、修改nginx配置文件,添加前端服务
配置文件路径:/opt/nginx1.20/conf/nginx.conf
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /opt/nginx1.20/logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 1223;
server_name localhost;
location / {
root /home/fr3000f/FR3000D/jar_bin/powerforecast_web;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /api {
proxy_pass http://127.0.0.1:8081/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
六、启动nginx
# 因为已建立系统软链接,故可以直接启动
nginx
# 查看是启动
ps ax | grep nginx
#显示两个nginx:
nginx: master process nginx
nginx: worker process
七、添加开机自启动
vim /etc/rc.d/rc.local
# 在最后一行添加:nginx