如何使用service命令来管理nginx
如何使用service命令来管理nginx???
如:
service nginx start
service nginx restart
service nginx stop
service nginx reload
如果要是使用 service 来管理nginx 需要把nginx 安装成为一个linux下的服务
1. 先创建一个文件nginx,里面写入以下shell脚本 如:
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
#
# 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=/var/run/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 /var/run/nginx.pid
} # reload nginx service functions.
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
2. 把这个文件复制到/etc/init.d目录下
cp ./nginx /etc/init.d
3. 修改这个文件为可执行的权限
chmod +x /etc/init.d/nginx
4. 把这个可执行文件加到服务服务中去
chkconfig --add nginx
之后就可以使用 service 命令来管理了!
如何使用service命令来管理nginx的更多相关文章
- 如何把apache和nginx 加入到系统服务,用service 命令来控制启动、停止
1 把apache 加入到系统服务,即用service 命令来控制Apache 启动.停止 如果Linux服务器上默认安装了httpd的话(用rpm -qa|grep httpd查看),那你就可以用 ...
- Virtualbox开机启动,service命令管理
#!/bin/bash#chkconfig:235 80 20#description:start or stop vbox#Author:Qty~20180502#OS:RedHatEnterpri ...
- linux安装Nginx 以及 keepalived 管理Nginx
linux安装Nginx 1.1将Nginx素材内容上传到/usr/local目录(pcre,zlib,openssl,nginx)(注意:必须登录用对这个文件具有操作权限的) 1.2安装pcre库 ...
- 玩转Windows服务系列——命令行管理Windows服务
说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令,命令行都是非常方便以及强大的工具. 接下来就看一下如何通过cmd命 ...
- linux service命令常见使用方法
service命令,顾名思义,就是用于管理Linux操作系统中服务的命令. 1. 声明:这个命令不是在所有的linux发行版本中都有.主要是在redhat.fedora.mandriva和centos ...
- 玩转Windows服务系列——命令行管理Windows服务
原文:玩转Windows服务系列——命令行管理Windows服务 说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令, ...
- CentOS中service命令与/etc/init.d的关系以及centos7的变化
缘由 由于个人经常在ubuntu和centos 系统中切换,习惯了以前的 ubuntu中 通过 /etc/init.d/xxx 进行软件服务控制.后来发现centos7中换了服务的控制方式:servi ...
- linux中注册系统服务—service命令的原理通俗
能够使用service命令进行操作的,就是已经注册成为linux的系统服务了.window中也可以注册成为系统服务的办法. service命令用的次数真不少,就是比较多的关联点,用了很多次了,还是有些 ...
- linux常用命令:service 命令
service命令用于对系统服务进行管理,比如启动(start).停止(stop).重启(restart).查看状态(status)等.相关的命令还包括chkconfig.ntsysv等,chkcon ...
随机推荐
- POJ1068 Parencodings(模拟)
题目链接. 分析: 水题. #include <iostream> #include <cstdio> #include <cstring> using names ...
- 2015WF有感
World Final题目连接:http://icpc.baylor.edu/worldfinals/problems/icpc2015.pdf 建议:可以倒序阅读来获得最直观的赛场体验... 2:1 ...
- (转载)PHP mb_substr函数在实际编码中的应用方法
(转载)http://developer.51cto.com/art/200912/166080.htm 我们在使用PHP语言进行实际编码中时,通常会遇到许多错误的出现,比如在截取字符串时会出现乱码等 ...
- 信用卡/借记卡充值p2p平台
第一部分信用卡/借记卡充值 首先信用卡尽量不要用于网贷,因为这样会有风险,对投资人和借款人都不利,况且银行的钱也不是那么好用的,对吧?但是也有很多朋友问我信用卡相关事宜,我在这里专门做个解答,信用卡用 ...
- Minimum Path Sum——LeetCode
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- webex录屏
你在寻找好用的录屏软件吗?商用级品质的 WebEx Recorder 就是一款优秀的录屏软件.WebEx Recorder可以录制全屏或指定窗口,可以设定是否包含声音,生成的文件体积极小且极清晰,录制 ...
- K - Rochambeau - poj2912(类似食物链)
一群小孩玩一个简单石头布布游戏,这些小孩会分成三组(组内可能没有人)+一个自由人(比翻译成裁判合理多了),同一组的小孩只会出同一种手势(不会变的),不过裁判可以出任意的手势,这些小孩能就会相互猜拳玩, ...
- driver.startActivity 启动app出现 An unknown server-side error occurred while processing the command
driver.startActivity("com.xxx.module.xxx", "com.xxx.module.xxx.hibox.ui.entry.EntryAc ...
- myeclipse快捷键收集整理
Ctrl+1 快速修复(最经典的快捷键,就不用多说了) Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加) Ctrl+Alt+↑ 复制当前行到上一行(复制增加) Alt ...
- Install the OpenStack command-line
Install the OpenStack command-line Install the prerequisite software python 2.7 or later note: Curre ...