您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Nginx跟PHP-FPM的启动/重启脚本

2025/8/14 20:07:15发布32次查看
nginx和php-fpm的启动/重启脚本
服务器上的nginx和php都是源码编译安装的,不支持类似以前的nginx(start|restart|stop|reload)了。自己动手丰衣足食。以下脚本应该在rhel, fedora,centos下都适用。
一、nginx启动脚本/etc/init.d/nginx#!/bin/bash
#
# startup script for nginx - this script starts and stops the nginxdaemon
#
# chkconfig:   - 8515
# description:  nginx is an http(s) server,http(s) reverse proxy and imap/pop3 proxy server
# processname: nginx
#config:     /usr/local/nginx/conf/nginx.conf
#pidfile:    /usr/local/nginx/logs/nginx.pid
# source function library.
. /etc/rc.d/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
# check that networking is up.
[ $networking = no ] && exit0
nginx=/usr/local/nginx/sbin/nginx
prog=$(basename $nginx)
nginx_conf_file=/usr/local/nginx/conf/nginx.conf
[ -f /etc/sysconfig/nginx ] && ./etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
   [ -x $nginx ] || exit 5
   [ -f $nginx_conf_file ] || exit 6
   echo -n $starting $prog:
   daemon $nginx -c $nginx_conf_file
   retval=$?
   echo
   [ $retval -eq 0 ] && touch$lockfile
   return $retval
}
stop() {
   echo -n $stopping $prog:
   killproc $prog -quit
   retval=$?
   echo
   [ $retval -eq 0 ] && rm -f$lockfile
   return $retval
}
restart() {
   configtest || return $?
   stop
   sleep 1
   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/null2>&1
}
case $1 in
   start)
       rh_status_q && exit 0
       $1
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product