nginx-二进制编译-脚本编写

把安装包下载到目录下 

安装编译环境

--rpm -ivh /opt/dvd/Packages/zlib-devel-1.2.7-17.e17.x86_64.rpm

-- rpm -q zlib-devel pcre-devel

--yum info pcre-devle

解压压缩包

-- tar zxf nginx-1.11.2.tar.gz

 

--./configure --prefix=/usr/local/nginx --user=nginx --group=nginx

make 进行预编译   

编译安装

--make install

 重启服务

--service nginx start

运行级别

写脚本控制README

--vi nginx.sh

查看端口80是否启动 

--ss -tanmlp | grep 80

拷贝

--cp nginx-running.sh  nginx

-- cp nginx /etc/init.d/

接管

--chkconfig --add nginx

--chkconfig nginx on

--chkconfig --list nginx

关闭防火墙

--iptables -F

--iptables -X

--setenforce 0

脚本内容:

#!/bin/bash
#chkconfig: - 99 20
#description nginx-server-scryt
nginx=/usr/local/nginx/sbin/nginx
case "$1" in
start)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx service running!"
else
echo "nginx service not running!"
$nginx
fi
;;
restart)
$nginx -s reload
if [ $? -eq 0 ]
then
echo "nginx server is begin restart"
else
echo "nginx server restart"
fi
;;
stop)
$nginx -s stop
if [ $? -eq 0 ]
then
echo "nginx server is stop"
else
echo "nginx server stop,try again"
fi
;;
status)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx server is running!"
else
echo "nginx server is not running.try to restart"
;;
*)
echo "Please enter (start | restart | stop | status)"
;;
esac
exit 0

 

posted on 2018-09-27 15:15  清欢渡w  阅读(192)  评论(0编辑  收藏  举报