#!/bin/bash
#ckconfig:
NGINX_PATH=/web/container/nginx-1.2.
NGINX_COMMAND=$NGINX_PATH/sbin/nginx
NGINX_PID=$NGINX_PATH/logs/nginx.pid
VERSION=1.2.
CONF=$ start()
{
if [ -f $NGINX_PID ];
then
echo "[Failure] Nginx is starting"
else
echo "[Success] Starting Nginx $VERSION"
#用户设置好后统一使用同一个用户操作
#/bin/su - nginx -c "$NGINX_PATH/nginx $CONF 1>/dev/null 2>/dev/null"
$NGINX_COMMAND $CONF >/dev/null >/dev/null
fi
} stop()
{
echo $NGINX_PID
if [ -f $NGINX_PID ];
then
echo "[Success] Stopping Nginx $VERSION"
$NGINX_COMMAND -s quit
#/bin/kill -QUIT $(eval "/bin/cat $NGINX_PID")
else
echo "[Failure] Stop Failure. Nginx isn't starting "
fi
} reload()
{
if test -f $NGINX_PID;
then
echo "[Success] Reloading Nginx $VERSION"
$NGINX_COMMAND -s reload
else
echo "[Failure] Reload Failure. Nginx isn't starting "
fi
} out()
{
if test -f $NGINX_PID;
then
echo "[Success] Exiting Nginx $VERSION"
$NGINX_COMMAND -s stop
#/bin/kill - $(eval "/bin/cat $NGINX_PID")
else
echo "[Failure] Exiting Failure . Nginx isn't starting "
fi
} case "$1" in
start)
start
;;
stop)
stop ;;
restart) stop
sleep
start
;;
exit)
out
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|restart|exit|reload}"
exit
;;
esac
exit
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0. version.
# chkconfig: -
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ {$NETWORKING} = "no" ] && exit
[ -x $nginxd ] || exit
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit
esac
exit $RETVAL

Centos 下Nginx 自启动脚本的更多相关文章

  1. centos下nginx启动脚本和chkconfig管理

    在安装完nginx后,重新启动需要“kill -HUP nginx进程编号”来进行重新加载,显然十分不方便.如果能像apache一样,直接通过脚本进行管理就方便多了. nginx官方早就想好了,也提供 ...

  2. nginx 自启动脚本

    nginx 自启动脚本 创建脚本 cd /etc/init.d vi nginx 脚本如下: #! /bin/bash # chkconfig: 35 85 15 # description: Ngi ...

  3. Nginx - Windows下Nginx初入门,附CentOS下Nginx的安装

    公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...

  4. Linux下nginx自启动配置

    1.在linux系统的/etc/init.d/目录下创建nginx文件 vim /etc/init.d/nginx 在脚本中添加一下命令(内容主要参考官方文档) #!/bin/sh # # nginx ...

  5. 话说Centos下nginx,php,mysql以及phpmyadmin的配置

    大话centos下部署phalcon框架 Centos还是ubuntu? 当我沿用这个标题的时候,心里在想"我能说我之前用的windows吗?",windows下xampp,wam ...

  6. Centos下 Nginx安装与配置

    网上找了好多资料.都很难找全,这里以这个目录为主,进行备注. Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttpd具有占有内存少,稳定性高等优势.它最常的用途是提供 ...

  7. CentOS下nginx php mysql 环境搭建

    CentOS下搭建PHP运行环境. 首先是在虚拟机上装好一个命令行的CentOS,如果只是弄服务器的话,不要装图形界面,会比较卡. 一.安装编译工具及库文件 yum -y install make z ...

  8. CentOS下编写shell脚本来监控MySQL主从复制的教程

    这篇文章主要介绍了在CentOS系统下编写shell脚本来监控主从复制的教程,文中举了两个发现故障后再次执行复制命令的例子,需要的朋友可以参考下 目的:定时监控MySQL主从数据库是否同步,如果不同步 ...

  9. 腾讯云Centos下Nginx反向代理Apache+Tomcat

    1. 安装Apahce, PHP, MySQL以及php连接mysql库的组件#yum -y install httpd php mysql mysql-server php-mysql     // ...

随机推荐

  1. WPF处理Windows消息

    WPF中处理消息首先要获取窗口句柄,创建HwndSource对象 通过HwndSource对象添加消息处理回调函数. HwndSource类: 实现其自己的窗口过程. 创建窗口之后使用 AddHook ...

  2. WPF中利用DynamicDataDisplay快速实现示波器功能

    DynamicDataDisplay控件是一个功能很强的绘图工具,除了能生成曲线外,还有很多其他功能,具体见http://dynamicdatadisplay.codeplex.com/.这里你也能下 ...

  3. pdf增加水印

    /// <summary> /// 为PDF添加水印或背景图片 /// </summary> /// <param name="strSourceFilePat ...

  4. linux工作队列

    工作队列一般用来做滞后的工作,比如在中断里面要做很多事,但是比较耗时,这时就可以把耗时的工作放到工作队列.说白了就是系统延时调度的一个自定义函数. 工作队列是实现延迟的新机制,从 2.5 版本 Lin ...

  5. easy ui easyui-linkbutton 禁用、启用

    <a id="btn_update_Shop" name="btn_update_Shop" class="easyui-linkbutton& ...

  6. easy ui 菜单和按钮(Menu and Button)

    http://www.zi-han.net/case/easyui/menu&button.html

  7. 【学习总结】【多线程】 线程 & 进程 & NSThread(多线程的一套API)

    一.进程和线程 1.什么是进程 进程是指在系统中正在运行的一个应用程序 每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内 比如同时打开 Chrome.Xcode,系统就会分别启动2个进 ...

  8. dubbo zookeeper模型

    本文摘自dubbo的官方文档,原文请参见: http://alibaba.github.io/dubbo-doc-static/User+Guide-zh.htm#UserGuide-zh-Zooke ...

  9. 1024: [SCOI2009]生日快乐 - BZOJ

    Description windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕.现在包括windy,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积的蛋 ...

  10. jquery下拉列表选中项改变时获取新选项的属性值

    $("#textSel").change(funtion(){ var selVal=$(this).val(); var selText=$("#textSel opt ...