1、找到合适的nginx资源包,可以去官网下载
这里用的是 nginx-1.24.0.tar.gz
2、上传下载下来的nginx软件包,并解压
tar zxvf nginx-1.24.0.tar.gz
cd nginx-1.24.0/
3、安装nginx
编译
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-http_stub_status_module --with-http_gzip_static_module
提示错误
./configure: error: SSL modules require the OpenSSL library.
暂不用SSL,重新修改配置
./configure --prefix=/usr/local/nginx --with-stream --with-http_stub_status_module --with-http_gzip_static_module
编译成功。
安装
make && make install
4、上传前端代码&修改配置代理
cd /usr/local/nginx/conf/
vim nginx.conf
root /home/front-end/;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
add_header Cache-Control no-cache;
add_header Cache-Control private;
add_header X-Frame-Options SAMEORIGIN;
}
## 业务
location /backend {
client_max_body_size 60m;
client_body_buffer_size 60M;
proxy_pass http://127.0.0.1:8007;
}
5、启动服务
cd /usr/local/nginx/sbin/
./nginx
./nginx -s reload