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