系統(tǒng)環(huán)境:
CentOS 7.3
依賴:
The GNU Compiler Collection
The PCRE Library
The zlib Library
OpenSSL
安裝依賴
yum -y groupinstall "開發(fā)工具"
# 如果語言環(huán)境是英語,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/
進(jìn)入nginx目錄
cd /usr/local/src/nginx-1.12.0/
預(yù)編譯
# 強(qiáng)烈建議使用prefix指定安裝目錄,方便以后直接刪除Nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre=/usr/local/pcre2 --with-zlib=/usr/local/zlib
安裝
make & make install
添加系統(tǒng)用戶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