安装依赖
# yum install gcc
# yum install pcre-devel
# yum install zlib zlib-devel
# yum install openssl openssl-devel
//一键安装上面四个依赖
# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
下载nginx的tar包
# cd /usr/local
# mkdir nginx
# cd nginx
//下载tar包
# wget http://nginx.org/download/nginx-xxxx.tar.gz
//解压
# tar -xvf nginx-xxx.tar.gz
安装nginx
# cd /usr/local/nginx
//执行命令
# ./configure
//执行make命令
# make
//执行make install命令
# make install
启动Nginx
//测试配置文件
# /nginx/sbin/nginx –t
//启动命令
# /nginx/sbin/nginx
//停止命令
# /nginx/sbin/nginx -s stop
配置集群
# cd /usr/local/nginx/conf
//修改nginx.conf文件,在http{}中添加下列语句
# vim nginx.conf
upstream web_app{
server 192.168.93.129:8080 weight=1;
server 192.168.93.130:8080 weight=1;
ip_hash;
}
server {
listen 8080;
server_name 192.168.93.128;
location / {
proxy_pass http://web_app;
}
}
client_max_body_size 100m;
注:windows环境搭建nginx参考博客:
https://www.cnblogs.com/xiaoblog/p/5960830.html
https://blog.csdn.net/qwlovedzm/article/details/52772409