一 安装
1.1 安装所以要依赖
yum -y install gcc gcc-c++ lrzsz pcre-devel zlib-devel openssl openssl-devel
1.2 解压文件
curl -O http://kode.huhuhahei.cn/index.php?user/publicLink\&fid=568dTMagXT7m-kmKWLpMy2Ium_O4mHbu6RypnzB8lOtS3cv6ZLXBz_VHvo4RIQRIeTsiExnsM2dKgfwWwERLc-mYsQz0G5HMzFcXIqPjr_YxsEpgvx8kZW7ROA\&file_name=/nginx-1.17.8.tar.gz
curl -O http://kode.huhuhahei.cn/index.php?user/publicLink\&fid=5893HDAqQsezkGTjTgdBpdWi1P3rXIdkydzX4ycPbFm4T6dcsUcvUEMpSNk4cnsjjN4TcfR56sDiSJeCRcM7dqJg8Dmfo5f7eO_0YftvwTkFukXd3sT88wuqR3cHetk\&file_name=/nginx-module-vts.tar.gz
curl -O http://kode.huhuhahei.cn/index.php?user/publicLink\&fid=1dcez7qeWIZHjLkOUxlkHeB745k1j20xnRlpCvUertRwRBSi_ESaGXhZj8FYGPfwdZ7sSHUWTMM5Qq0Na7YjwVpR8OsbIGT4RZy1E8mo3cxanSFSY5xZBo6QbrbYuX6V0icUbzQ0DoDNGJjcMw\&file_name=/headers-more-nginx-module-0.33.tar.gz
tar xf nginx-1.17.8.tar.gz -C /usr/src
tar xf nginx-module-vts.tar.gz -C /usr/src/
tar xf headers-more-nginx-module-0.33.tar.gz -C /usr/src/
1.3 编译
cd /usr/src/nginx-1.17.8/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --add-module=../headers-more-nginx-module-0.33 --with-stream --with-stream_ssl_preread_module --add-module=../nginx-module-vts/
1.4 安装
make && make install
二 优化
2.1 创建软连接
ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
2.2 创建server控制
#!/bin/bash
#chkconfig: - 99 20
#description:Nginx Service l Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
添加权限
chmod +x /etc/init.d/nginx
添加chkconfig
chkconfig --add nginx
启动服务
service nginx start