1.安装依赖环境
[root@ c7-41 ~]# yum -y install gcc pcre-devel zlib-devel
2.下载nginx
[root@ c7-41 ~]# wget http://nginx.org/download/nginx-1.17.10.tar.gz
3.解压并检测环境
[root@ c7-41 ~]# tar zxf nginx-1.17.10.tar.gz
[root@ c7-41 ~]# cd nginx-1.17.10/
[root@ c7-41 nginx-1.17.10]# ./configure
4.编译安装
[root@ c7-41 nginx-1.17.10]# make && make install
5.修改配置文件
[root@ c7-41 nginx-1.17.10]# cat /usr/local/nginx/conf/nginx.conf | sed -n "34,36p"
upstream webs{
server 10.0.0.43:8080;
}
[root@ c7-41 nginx-1.17.10]# cat /usr/local/nginx/conf/nginx.conf | sed -n "45,49p"
location / {
root html;
index index.html index.jsp index.htm;
proxy_pass http://webs;
}
6.启动
[root@ c7-41 nginx-1.17.10]# /usr/local/nginx/sbin/nginx