一
#
# chkconfig:
# description: Nginx is an HTTP(S) server
# processname: nginx
# config: /usr/local/nginx/conf/nginx
# pidfile: /usr/local/nginx/logs/nginx
# Source function library
# Source networking configuration
# Check that networking is up
[ "$NETWORKING" = "no" ] && exit
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx
[
lockfile=/var/lock/subsys/nginx
start() {
[
[
echo
daemon $nginx
retval=$?
echo
[ $retval
return $retval
}
stop() {
echo
killproc $prog
retval=$?
echo
[ $retval
return $retval
}
restart() {
configtest || return $?
stop
sleep
start
}
reload() {
configtest || return $?
echo
killproc $nginx
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null
}
case "$
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force
force_reload
;;
status)
rh_status
;;
condrestart|try
rh_status_q || exit
;;
*)
echo $"Usage: $
exit
esac
編輯好後保存
sudo /sbin/chkconfig nginx on
# 檢查一下
sudo /sbin/chkconfig
nginx
完成!可以使用以下命令管理Nginx了
代碼如下 復制代碼 service nginx startservice nginx stop
service nginx restart
service nginx reload
/etc/init
/etc/init
/etc/init
/etc/init
二
#
# Startup script for the PHP
#
# chkconfig:
# description: PHP is an HTML
# processname: php
# config: /usr/local/php/etc/php
# Source function library
PHP_PATH=/usr/local
DESC="php
NAME=php
# php
DAEMON=$PHP_PATH/php/sbin/$NAME
# 配置文件路徑
CONFIGFILE=$PHP_PATH/php/etc/php
# PID文件路徑(在php
PIDFILE=$PHP_PATH/php/var/run/$NAME
SCRIPTNAME=/etc/init
# Gracefully exit if the package has been removed
test
rh_start() {
$DAEMON
}
rh_stop() {
kill
}
rh_reload() {
kill
}
case "$
start)
echo
rh_start
echo "
;;
stop)
echo
rh_stop
echo "
;;
reload)
echo
rh_reload
echo "reloaded
;;
restart)
echo
rh_stop
sleep
rh_start
echo "
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&
exit
;;
esac
exit
編輯好後保存
sudo /sbin/chkconfig php
# 檢查一下
sudo /sbin/chkconfig
php
完成!可以使用以下命令管理php
service php
service php
service php
service php
/etc/init
/etc/init
/etc/init
/etc/init
From:http://tw.wingwit.com/Article/program/Java/gj/201405/30815.html