1、gcc 安装
yum install gcc-c++
2、PCRE pcre-devel 安装
yum install -y pcre pcre-devel
3、zlib 安装
yum install -y zlib zlib-devel
4、OpenSSL 安装
yum install -y openssl openssl-devel
5、下载安装包,官网地址:https://nginx.org/en/download.html
wget https://nginx.org/download/nginx-1.19.9.tar.gz
6、解压并进入nginx目录
(1)使用默认配置:
./configure
(2)自定义配置:
指定安装目录:–prefix=/usr/local/nginx
添加ssl模块:–with-http_ssl_module
显示客户端状态模块:–with-http_stub_status_module
支持TCP转发模块:–with-stream
./configure –prefix=/usr/local/nginx –with-http_ssl_module –with-http_stub_status_module –with-stream –with-stream_ssl_module
7、编译安装
make
make install
8、查找安装路径
whereis nginx
9、相关命令
./nginx
./nginx -s stop 此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
./nginx -s quit 此方式停止步骤是待nginx进程处理任务完毕进行停止
./nginx -s reload
10、设置开机自启动
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:chmod 755 rc.local