#!/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. Mac下使用sublime text 2开发Python

    入门虽易, 熟练不易, 且行且珍惜 简介:这只是简单介绍一个好的文本工具sublime text的使用,如果要获得详细的教程可以去看这本书<Sublime Productivity>和一些 ...

  2. Cent os关机与重启命令详解

    Cent OS关机与重启命令详解 分类: Linux2012-10-02 14:06 5553人阅读 评论(0) 收藏 举报 centoslinuxsignallogin工作windows Linux ...

  3. Unity3d之Socket UDP协议

    原文地址:http://blog.csdn.net/dingkun520wy/article/details/49201245 (一)Socket(套接字)UDP协议的特点 1.是基于无连接的协议,没 ...

  4. 解决mysql中表字符集gbk,列字符集Latin1,python查询乱码问题

    最近在公司碰到一个异常蛋疼的情况,mysql数据库中,数据库和表的字符集都是'gbk',但是列的字符集却是'latin1',于是蛋疼的事情出现了. 无论我连接字符串的`charset`设置为`gbk` ...

  5. C# DataTable

    http://www.cnblogs.com/xun126/archive/2010/12/30/1921557.html http://msdn.microsoft.com/zh-cn/librar ...

  6. mybatis--面向接口编程

    如果使用hiberante作为dao层,常用的方式是:定义一个dao层接口包(com.dao.service)然后在定义一个dao层接口实现包(com.dao.service.impl),这样定义结构 ...

  7. 如何在JavaScript里防止事件函数的高频触发和调用

    网页中JavaScript最基本的功能是监听或响应用户的动作,这非常的有用.用户的动作有些频率非常高,有的十分罕见.有些监听器函数的执行如闪电般完成,而有些繁重的会把浏览器拖死.拿浏览器窗口的resi ...

  8. PAT-乙级-1018. 锤子剪刀布 (20)

    1018. 锤子剪刀布 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大家应该都会玩“锤子剪刀布”的游 ...

  9. notepad++ 开启/关闭 记住最后打开的文件

    开启记住最后打开的文件 1) 6.3以前版本如下设置: 设置-->首选项-->其他 把左下角的 "记住最后打开文件" 勾选. 2) 6.3以后版本如下设置: 设置--& ...

  10. leetcode 练习1 two sum

    leetcode 练习1  two sum whowhoha@outlook.com 问题描述 Given an array of integers, return indices of the tw ...