Centos 下Nginx 自启动脚本
#!/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 自启动脚本的更多相关文章
- centos下nginx启动脚本和chkconfig管理
在安装完nginx后,重新启动需要“kill -HUP nginx进程编号”来进行重新加载,显然十分不方便.如果能像apache一样,直接通过脚本进行管理就方便多了. nginx官方早就想好了,也提供 ...
- nginx 自启动脚本
nginx 自启动脚本 创建脚本 cd /etc/init.d vi nginx 脚本如下: #! /bin/bash # chkconfig: 35 85 15 # description: Ngi ...
- Nginx - Windows下Nginx初入门,附CentOS下Nginx的安装
公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...
- Linux下nginx自启动配置
1.在linux系统的/etc/init.d/目录下创建nginx文件 vim /etc/init.d/nginx 在脚本中添加一下命令(内容主要参考官方文档) #!/bin/sh # # nginx ...
- 话说Centos下nginx,php,mysql以及phpmyadmin的配置
大话centos下部署phalcon框架 Centos还是ubuntu? 当我沿用这个标题的时候,心里在想"我能说我之前用的windows吗?",windows下xampp,wam ...
- Centos下 Nginx安装与配置
网上找了好多资料.都很难找全,这里以这个目录为主,进行备注. Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttpd具有占有内存少,稳定性高等优势.它最常的用途是提供 ...
- CentOS下nginx php mysql 环境搭建
CentOS下搭建PHP运行环境. 首先是在虚拟机上装好一个命令行的CentOS,如果只是弄服务器的话,不要装图形界面,会比较卡. 一.安装编译工具及库文件 yum -y install make z ...
- CentOS下编写shell脚本来监控MySQL主从复制的教程
这篇文章主要介绍了在CentOS系统下编写shell脚本来监控主从复制的教程,文中举了两个发现故障后再次执行复制命令的例子,需要的朋友可以参考下 目的:定时监控MySQL主从数据库是否同步,如果不同步 ...
- 腾讯云Centos下Nginx反向代理Apache+Tomcat
1. 安装Apahce, PHP, MySQL以及php连接mysql库的组件#yum -y install httpd php mysql mysql-server php-mysql // ...
随机推荐
- LeetCode之Single Number以及拓展
Problem 1:一个数组中有一个数字a只出现一次,其他数字都出现了两次.请找出这个只出现一次的数字? 考察知识点:异或运算 思路:比如数字 b^b = 0 a^0 = a 因此,可以将数组 ...
- Python通过Manager方式实现多个无关联进程共享数据
Python官方文档 Python实现多进程间通信的方式有很多种,例如队列,管道等. 但是这些方式只适用于多个进程都是源于同一个父进程的情况. 如果多个进程不是源于同一个父进程,只能用共享内存,信号量 ...
- 【MongoDB】 安装为windows services
参考 http://stackoverflow.com/questions/2404742/how-to-install-mongodb-on-windows # mongodb.conf # da ...
- C# 将datatable 转换json
public static string DataTableToJson(DataTable dt) { StringBuilder jsonBuilder = new StringBuilder() ...
- Objective-C程序结构及语法特点
程序文件分为头文件(.h)和实现文件(.m): 使用#import关键字将所需的头文件导入程序,并且可以避免程序重复引用相同的头文件: @autoreleasepool { … } 自动释放池: 符号 ...
- 2336: [HNOI2011]任务调度 - BZOJ
一道随机算法的题目 随便用什么随机算法 首先我们可以想到枚举类型3的最终类型,然后再做 先贪心出一个较优的序列,首先我们知道肯定是在A机器上先做完类型1的事件再做类型2的事件,机器B也类似,因为这些没 ...
- [转]LINQ语句之Select/Distinct和Count/Sum/Min/Max/Avg
在讲述了LINQ,顺便说了一下Where操作,这篇开始我们继续说LINQ语句,目的让大家从语句的角度了解LINQ,LINQ包括LINQ to Objects.LINQ to DataSets.LINQ ...
- [转载]jquery ajax/post/get 传参数给 mvc的action
jquery ajax/post/get 传参数给 mvc的action 1.ActionResult Test1 2.View Test1.aspx 3.ajax page 4.MetaO ...
- LESS CSS 总结
1.LESS 简介 less是动态的样式表语言,通过简洁明了的语法定义,使编写 CSS 的工作变得非常简单 类似Jquery框架 中文网站: http://www.lesscss.net/ 2.编译工 ...
- Win7 默认hosts文件
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP f ...