一、下载Nginx
官网下载地址:http://nginx.org/en/download.html
二、安装
操作系统:CentOS Linux release 8.3.2011
# 新建源码目录
mkdir nginx-src
# 进入该目录
cd nginx-src
# 下载 Nginx 源码准备编译
wget http://nginx.org/download/nginx-1.20.1.tar.gz
# 将下载的压缩包解压
tar -xzf nginx-1.20.1.tar.gz
# 进入源码包
cd ./nginx-1.20.1
# 指定安装目录为 /root/nginx
./configure --prefix=/root/nginx
# 编译
make
# 编译并安装(首次安装)
make install
三、可能遇到的问题
# 报错:c compiler cc is not found
yum -y install gcc-c++
# 报错:./configure: error: the HTTP rewrite module requires the PCRE library.
yum -y install pcre-devel
# 报错:./configure: error: the HTTP gzip module requires the zlib library.
yum install -y zlib-devel
# 报错:-bash: make: command not found
yum -y install gcc automake autoconf libtool make
四、Nginx 语法高亮显示
# 在~ 目录下新建 .vim 目录
cd ~
mkdir .vim
# 进入 Nginx 源码根目录
cd nginx-1.20.1
# 拷贝对应语法规则到 .vim 目录
cp –r contrib/vim/* ~/.vim/