合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
### 1.下载nginx安装包 下载地址:[http://nginx.org/en/download.html](http://nginx.org/en/download.html) ### 2.解压 ``` tar -zxvf nginx-1.18.0.tar.gz ``` ![](https://img.kancloud.cn/66/61/6661b49dc2a11f08e5e152453eacb0ea_714x177.png) ### 3.安装执行编译依赖 ``` yum -y install gcc openssl openssl-devel pcre-devel zlib zlib-devel ``` ![](https://img.kancloud.cn/38/68/386844e82d92005c96a14194de514344_931x244.png) ### 4.编译安装 ``` ./configure //如需部署https需安装ssl模块请执行 ./configure --with-http_ssl_module make make install ``` ![](https://img.kancloud.cn/10/be/10bedb59ebd2fcdf590d951e85c62564_1271x322.png) ### 5.启动 ``` cd /sbin ./nginx ``` ### 6.验证nginx是否启动 关闭防火墙访问地址默认80端口 ``` //查看nginx进程 ps -ef | grep nginx //关闭nginx进程 kill -9 15623 ``` ![](https://img.kancloud.cn/45/0c/450cd5f03c096da94956aa2e11676e0e_689x82.png) ### 7.设置nginx转发代理配置目录 ``` cd /usr/local/nginx/conf vi nginx.conf ``` ![](https://img.kancloud.cn/02/e4/02e4c0d52e3e062f63221e8d4e0bb203_1232x104.png) 添加目录路径,可按需求设置 ``` //匹配conf.d下以.conf结尾的文件 include /usr/local/nginx/conf.d/*.conf; ``` ![](https://img.kancloud.cn/e0/ec/e0ecbe6f29312b67af6834119e0f8bfc_513x389.png) ### 8.常用命令:进入nginx/sbin ``` 1.重新加载配置文件: ./nginx -s reload 2.停止nginx访问: ./nginx -s stop 3.启动nginx: ./nginx ``` ### 9.前端路径和端口配置:进入nginx/conf.d ``` 查看配置文件:vim xxx.conf 修改:i 退出修改::q 退出并保存::wq ``` ![](https://img.kancloud.cn/7d/bd/7dbdff715ccd3998c54562ceea2f0705_1399x127.png) ![](https://img.kancloud.cn/b7/ff/b7ff3be7c7e1b4400b6745af1383bfdf_1540x930.png) ### 10.防火墙 ``` 查看已开放的tcp/ip端口:netstat -tuln 添加9000端口:sudo firewall-cmd --zone=public --add-port=9000/tcp --permanent 重启防火墙:sudo firewall-cmd --reload ```