#======================================= 添加geoip2模块 ====================================
#下载
cd $SoftDir && wget -q
#解压:
unzip ngx_http_geoip2_module-master.zip >> $LOG_INS 2>&1
#======================================= 添加libuwind ====================================
#下载:
cd $SoftDir && wget -q
#解压:
tar zxf libunwind-1.1.tar.gz
#进入解压目录,配置编译参数::
cd ./libunwind-1.1 && ./configure >> $LOG_INS 2>&1
#编译及安装
MAKE && MAKE_INS
#======================================= 添加gperftools ====================================
#下载:
cd $SoftDir && wget -q
#解压:
unzip gperftools-master.zip
#进入解压目录,执行autogen.sh 生产配置文件:
cd ./gperftools-master && ./autogen.sh >> $LOG_INS 2>&1
#配置编译参数:
if [ `echo $?` -eq 0 ];then
./configure >> $LOG_INS 2>&1
else
exit
fi
#编译及安装
MAKE && MAKE_INS
#======================================= 安装Tengine 2.1.0 ====================================
#下载
cd $SoftDir && wget -q
#解压:
tar zxf nginx-1.8.0.tar.gz
#进入解压目录,配置编译参数:
cd ./nginx-1.8.0 && ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --http-log-path=/var/log/nginx_access.log --with-google_perftools_module --with-pcre=/usr/local/src/pcre-8.37 --with-openssl=/usr/local/src/openssl-1.0.2 --add-module=/usr/local/src/ngx_http_geoip2_module-master >> $LOG_INS 2>&1
#编译及安装
MAKE && MAKE_INS
#设置软链接
ln -s /usr/local/lib/libmaxminddb.so.0 /usr/lib64
ln -s /usr/local/lib/libprofiler.so.0 /usr/lib64
ln -s /usr/local/lib/libunwind.so.8 /usr/lib64
#检测初始化完成的nginx 配置是否有问题
/usr/local/nginx/sbin/nginx -t
if [ `echo $?` -eq 0 ];then
echo "Nginx installed successfully!"
else
exit
fi
#创建nginx 启动脚本
cat <<EOF > /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
echo -n \$"Starting \$prog: "
mkdir -p /dev/shm/nginx_temp
daemon \$NGINX_SBIN -c \$NGINX_CONF
RETVAL=\$?
echo
return \$RETVAL
}
stop() {
echo -n \$"Stopping \$prog: "
killproc -p \$NGINX_PID \$NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=\$?
echo
return \$RETVAL
}
reload(){
echo -n \$"Reloading \$prog: "
killproc -p \$NGINX_PID \$NGINX_SBIN -HUP
RETVAL=\$?
echo
return \$RETVAL
}
restart(){
stop
start
}
configtest(){
\$NGINX_SBIN -c \$NGINX_CONF -t
return 0
}
case "\$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: \$0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit \$RETVAL
EOF
#赋予脚本可执行权限
chmod 755 /etc/init.d/nginx
#备份nginx主配置文件
\cp /usr/local/nginx/conf/nginx.conf{,.bak}