centos 7.2編譯安裝nginx-1.12.0


#下載nginx openssl,pcre,zlib
wget http://nginx.org/download/nginx-1.12.0.tar.gz
wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.37.tar.gz
wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz?download

#解壓nginx openssl,pcre,zlib
tar -zxvf nginx-1.12.0.tar.gz
tar -zxvf openssl-1.1.0e.tar.gz
tar -zxvf pcre-8.37.tar.gz
tar -zxvf zlib-1.2.11.tar.gz?download


#進入源碼目錄
cd openssl-1.1.0e

#配置
./config --prefix=/server/download/nginx/openssl --openssldir=/server/download/nginx/openssl/conf

#編譯安裝
make && make install

#檢驗安裝(如果報錯是文件路徑不對的問題為下面兩個文件設置軟連接)
ln -s /server/download/nginx/openssl/bin/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /server/download/nginx/openssl/bin/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
/server/download/nginx/openssl/bin/openssl version -a

 

#進入源碼目錄
cd pcre-8.37


#安裝C ++編譯器
yum install -y gcc gcc-c++

#執行配置
./configure --prefix=/server/download/nginx/pcre/

#編譯安裝
make && make install

 

 

#進入源碼目錄
cd zlib-1.2.11

#配置
./configure --prefix=/server/download/nginx/zlib/

# 編譯安裝
make && make install

 

 

#進入安裝目錄
cd nginx-1.8.0

 

#配置(使用openssl、pcre、zlib的源碼路徑)
./configure \
--user=www \
--group=www \
--prefix=/server/service/nginx \
--with-http_ssl_module \
--with-openssl=/server/download/nginx/openssl-1.1.0e \
--with-pcre=/server/download/nginx/pcre-8.37 \
--with-zlib=/server/download/nginx/zlib-1.2.11 \
--with-http_stub_status_module \
--with-threads


#編譯安裝
make && make install

 

#驗證
/usr/local/nginx/sbin/nginx -V

#添加用戶跟用戶組

/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www

 

#啟動
/server/service/nginx/sbin/nginx -c /server/service/nginx/conf/nginx.conf

./nginx -s reload


#查詢nginx主進程號
ps -ef | grep nginx
#停止進程
kill -QUIT 主進程號
#快速停止
kill -TERM 主進程號
#強制停止
pkill -9 nginx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM