nginx、php-fpm启动脚本
Nginx官方启动脚本
//service nginx stop|start|restart|reload
touch /etc/init.d/nginx
chmod nginx
vi /etc/init.d/nginx
红色区域路径,根据自己路径修改。修改后可以service nginx stop|start|restart|reload
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: -
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit nginx="/usr/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {
# make required directories
user=`$nginx -V >& | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -n "$user" ]; then
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V >& | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f `
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
fi
} start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
configtest || return $?
stop
sleep
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$nginx -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac
php-fpm启动脚本
service php-fpm stop|start|restart|reload
内容如下
#! /bin/sh ### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start:
# Default-Stop:
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO prefix=/usr/local/php
exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_config=${prefix}/lib/php.ini php_opts="-c $php_config --fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () {
try= while test $try -lt ; do case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;; 'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac echo -n .
try=`expr $try + `
sleep done } case "$1" in
start)
echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != ] ; then
echo " failed"
exit
fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then
echo " failed"
exit
else
echo " done"
fi
;; stop)
echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit
else
echo " done"
fi
;; status)
if [ ! -r $php_fpm_PID ] ; then
echo "php-fpm is stopped"
exit
fi PID=`cat $php_fpm_PID`
if ps -p $PID | grep -q $PID; then
echo "php-fpm (pid $PID) is running..."
else
echo "php-fpm dead but pid file exists"
fi
;; force-quit)
echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then
echo " failed"
exit
else
echo " done"
fi
;; restart)
$ stop
$ start
;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -USR2 `cat $php_fpm_PID` echo " done"
;; *)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"
exit
;; esac
nginx、php-fpm启动脚本的更多相关文章
- gitlab6 nginx配置和启动脚本
gitlab6 nginx配置和启动脚本 cheungmine 2013-10 最近把gitlab安装到了ubuntu12.04.3的虚拟机上了.参考: https://github.com/gitl ...
- nginx二进制编译-启动脚本编写
首先先把这个文件上传到root目录下,并解压 #tar zxf nginx-1.11.2.tar.gz 写脚本 # vi nginx-running.sh 内容如下 #!/bin/bash #chkc ...
- nginx init 官方启动脚本
#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # descrip ...
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
centos LNMP第一部分环境搭建 LAMP安装先后顺序 LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/local/php/{ ...
- linux nginx 启动脚本
linux nginx 启动脚本 [root@webtest76 ~]# vi /etc/init.d/nginx #!/bin/bash # nginx Startup script for the ...
- Nginx 启动脚本/重启脚本
第一步先运行命令关闭nginx sudo kill `cat /usr/local/nginx/logs/nginx.pid` 第二步 vi /etc/init.d/nginx 输入以下内容 #!/b ...
- redhat nginx随机启动脚本
开机自动启动nginx 1. 扔脚本进去/etc/init.d/ 2. 授权 chmod +x nginx 3. 一旦抛出:binsh^M错误就执行编码改写 设置do ...
- nginx启动脚本,手动编辑
nginx启动脚本,手动编辑 #! /bin/bash # chkconfig: - # description: nginx service XDIR=/www/server/nginx DESC= ...
- win nginx + php bat启动/停止脚本
启动脚本 @echo offREM Windows 下无效REM set PHP_FCGI_CHILDREN=5 REM 每个进程处理的最大请求数,或设置为 Windows 环境变量set PHP_F ...
随机推荐
- 2019-7-3-如何通过命令行-msbuild-编译项目
title author date CreateTime categories 如何通过命令行 msbuild 编译项目 lindexi 2019-07-03 19:12:19 +0800 2019- ...
- activeMQ消息队列安装配置
1. 下载 到官网下载最新版本,有windows版本和linux版本的. http://activemq.apache.org/download.html 2. windows下部署 Activ ...
- SPOJ - LOCKER
SPOJ - LOCKERhttps://vjudge.net/problem/45908/origin暴力枚举2-102 23 34 2 25 2 36 3 37 2 2 38 2 3 39 3 3 ...
- python+selenium中webdriver相关资源
Chrome chrome的webdriver : http://chromedriver.storage.googleapis.com/index.html chrome的webdriver需要对 ...
- (转载)——Centos下安装Redis(原文地址:http://www.nnzhp.cn/archives/169)
原文地址:http://www.nnzhp.cn/archives/169 今天介绍一下redis,重点介绍一下redis的安装. Redis 是一个基于内存的高性能key-value数据库,数据都保 ...
- 线性dp——cf1032
升维来保存第i位按j是否可行,然后枚举i-1个的状态,用5*5n就可以完成递推 /* dp[i][j]==0表示第i步按j不可行 */ #include<bits/stdc++.h> us ...
- win7+64位笔记本安装TensorFlow CPU版
最近要用到Keras框架,而Keras是基于Theano或Tensorflow框架安装的,所以首先要准备底层框架的搭建. 在网上看了一大堆教程头昏脑涨,随便挑了个试一试,竟然捣鼓成功了,记录一下安装过 ...
- javaweb的几种开发模式
1.MVC模式基础 1.1.MVC模式简介 MVC是一种架构型模式,它本身并不引入新的功能,只是用来指导我们改善应用程序的架构,使得应用的模型和视图相分离,从而达到更好的开发和维护效率.在MVC模式中 ...
- 图片转成base64 跨域等安全限制及解决方案
把其他域的图片在canvas中转换为base64时,会遇到跨域安全限制. 目前,唯一可行的方案是,把图片文件以arraybuffer的形式ajax下载下来,然后直接转base4. 但是,这样有个毛病, ...
- 用docker部署zabbix
官方文档 https://www.zabbix.com/documentation/3.4/zh/manual/installation/containers 1 启动一个空的Mysql服务器实例 d ...