准备工作
下载Nginx
进入官方下载地址下载最新稳定版,此处下载为nginx-1.18.0。使用WinSCP上传至目录/usr/local/
安装依赖库
- pcre
pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式。
yum install -y pcre pcre-devel
- zlib
zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip。
yum install -y zlib zlib-devel
- openssl
openssl是web安全通信包。
yum install -y openssl openssl-devel
安装Nginx
- 解压
[root@iZbp1a30f9quwpuofd5v7aZ local]# tar zxvf nginx-1.18.0.tar.gz
- 编译 切换到解压后的根目录,执行依次以下三个命令。
./configure
make
make install
- 切换到
/usr/local/nginx/sbin/目录,启动ngxin。
./nginx
Nginx相关命令
# cd 到根目录下
# 启动nginx
./nginx
# 重载nginx
./nginx -s reload
# 关闭nginx
./nginx -s stop