系统环境:
CentOS 7.3
依赖:
The GNU Compiler Collection
The PCRE Library
The zlib Library
OpenSSL
安装依赖
yum -y groupinstall "开发工具"
# 如果语言环境是英语,yum groupinstall "Development Tools"
yum -y install pcre-devel zlib-devel openssl-devel
下载nginx源码
wget -P /usr/local/src/ http://nginx.org/download/nginx-1.12.0.tar.gz
解压
tar -zxvf /usr/local/src/nginx-1.12.0.tar.gz -C /usr/local/src/
进入nginx目录
cd /usr/local/src/nginx-1.12.0/
预编译
# 强烈建议使用prefix指定安装目录,方便以后直接删除Nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre=/usr/local/pcre2 --with-zlib=/usr/local/zlib
安装
make & make install
添加系统用户nginx
useradd -r nginx
测试nginx是否安装成功
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful