Tengine启动方式做成service方式 1.创建服务命令如下: #cd /etc/rc.d/init.d #touch nginx #vi nginx nginx内容如下所示 #!/bin/bash # # nginx This shell script takes care of starting and stopping # standalone nginx # software version 2.1.2 # description: nginx service # processname: nginx # config file: # Source function library. . /etc/rc.d/init.d/functions nginx="/u02/software/tengine/sbin/nginx" prog=$(basename $nginx) #第一行是防止nginx自启动抛出异常80端口被占用,可自行修改默认端口号 #如果停止命令和开始命令是分开的,不在同一次执行,则不会出现异常 start(){ chmod 755 /u02/software/tengine/sbin/nginx /u02/software/tengine/sbin/nginx echo "nginx start success" } stop(){ pid=`ps -ef | grep "nginx" | grep -v "grep" | awk '{print $2}'` if [ -n "$pid" ]; then kill $pid echo "nginx stop success" else echo "no nginx service is running." fi } nginx_status() { status $prog } restart(){ stop start } case "$1" in start) start ;; stop) stop ;; status) nginx_status ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit 2.使用命令管理nginx服务 #service nginx status #service nginx start #service nginx stop #service nginx restart
版权声明:本文为myzksky原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。