码迷,mamicode.com
首页 > 其他好文 > 详细

nginx脚本编译安装

时间:2018-07-26 18:31:47      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:href   ppi   c++   starting   val   chmod   编译配置   configure   evel   

vi ng_install.sh
#!/bin/bash
pkill -9 mysql
date +%Y-%m-%d-%H-%M
rm -rf /usr/local/nginx*
/bin/rpm -e $(/bin/rpm -qa | grep nginx|xargs) --nodeps
echo "============================检查基本插件安装=================================="
yum -y install wget curl pcre pcre-devel zlib zlib-devel gcc gcc-c++
cd /opt/ && wget -c http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz && cd nginx-1.14.0

echo "============================编译配置安装nginx=================================="
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install

echo "============================检查nginx配置是否正确=================================="
/usr/local/nginx/sbin/nginx -t
echo "============================配置启动脚本应用=================================="

cat > /etc/init.d/nginx << EOF
#!/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

echo "============================配置及启动nginx=================================="
chmod 755 /etc/init.d/nginx && chkconfig --add nginx && chkconfig nginx on
/etc/init.d/nginx start
echo "============================查看状态================================="
ps -ef|grep nginx && netstat -tunpl

nginx脚本编译安装

标签:href   ppi   c++   starting   val   chmod   编译配置   configure   evel   

原文地址:http://blog.51cto.com/10158955/2150638

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!