tar xf nginx-1.18.0.tar.gz -C /usr/local/src
[root@centos7 /usr/local/src/nginx-1.18.0]#./configure --prefix=/apps/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
#编译安装
[root@centos7 ~]#make -j 4 && make -j 4 install
#创建软链接
[root@centos7 ~]#ln -s /apps/nginx/sbin/nginx /usr/sbin/
#添加一行设置子配置文件存放的目录
[root@centos7 ~]#vim /apps/nginx/conf/nginx.conf
#在配置文件的最后一行插入
include /apps/nginx/conf/conf.d/*.conf;
#新建存放目录
[root@centos7 ~]#mkdir /apps/nginx/conf/conf.d
#添加监听端口
[root@centos7 ~]#vim /apps/nginx/conf/conf.d/web01.conf
```
server {
listen 81;
server_name www.web01.com;
location / {
proxy_pass http://10.0.0.4/littlegames/;
}
}
```
#杀死进程
[root@centos7 ~]#pkill -9 nginx
#启动nginx进程
[root@centos7 ~]#nginx
#或者重新加载
[root@centos7 ~]#nginx -s reload