linux 把nginx加入到系统服务的方法
一。首先写一个shell脚本,脚本名称:nginx
<pre>
#! /bin/bash
# chkconfig: 35 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start(){
$DAEMON || echo -n " already running"
}
d_stop() {
$DAEMON -s quit || echo -n " not running"
}
d_reload() {
$DAEMON -s reload || echo -n " counld not reload"
}
case "$1" in
start)
echo -n "Starting $DESC:$NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC:$NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 2
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3
;;
esac
exit 0
</pre>

二。将shell脚本放入到 /etc/rc.d/init.d/中,并执行下列命令
1:chmod +x /etc/rc.d/init.d/nginx (设置可执行权限)
2:chkconfig --add nginx (添加系统服务)

linux 把nginx加入到系统服务的方法的更多相关文章

  1. Linux下Nginx安全证书ssl配置方法

    分享下我是如何一步步在Nginx上配置SSL的.首先,确保安装了OpenSSL库,并且安装Nginx时使用了–with-http_ssl_module参数. 初学者或者菜鸟建议使用LNMP进行一键安装 ...

  2. linux中nginx重定向方法总结

    linux中nginx 301重定向跳转方法总结 第一种情况:访问aaaaaaa站定向到bbbbbbbbbbb站 复制代码代码如下: server { server_naaaaaaame www.aa ...

  3. linux写系统服务的方法

    linux写系统服务的方法 2.1 首先编写demo程序:hello.c<pre>#include <stdio.h> # chkconfig: 2345 10 90 main ...

  4. 【转】Linux下nginx配置https协议访问的方法

    一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...

  5. 如何把apache和nginx 加入到系统服务,用service 命令来控制启动、停止

    1 把apache 加入到系统服务,即用service 命令来控制Apache 启动.停止  如果Linux服务器上默认安装了httpd的话(用rpm -qa|grep httpd查看),那你就可以用 ...

  6. linux下Nginx配置文件(nginx.conf)配置设置详解(windows用phpstudy集成)

    linux备份nginx.conf文件举例: cp /usr/local/nginx/nginx.conf /usr/local/nginx/nginx.conf-20171111(日期) 在进程列表 ...

  7. linux下查询进程占用的内存方法总结

    linux下查询进程占用的内存方法总结,假设现在有一个「php-cgi」的进程 ,进程id为「25282」.现在想要查询该进程占用的内存大小.linux命令行下有很多的工具进行查看,现总结常见的几种方 ...

  8. Linux中Nginx安装与配置详解

    转载自:http://www.linuxidc.com/Linux/2016-08/134110.htm Linux中Nginx安装与配置详解(CentOS-6.5:nginx-1.5.0). 1 N ...

  9. 详解Linux(centos7)下安装OpenSSL安装图文方法

    OpenSSL是一个开源的ssl技术,由于我需要使用php相关功能,需要获取https的文件所以必须安装这个东西了,下面我整理了两种关于OpenSSL安装配置方法. 安装环境:  操作系统:CentO ...

随机推荐

  1. 金融类openapi

    股市URL解析 http://money.finance.sina.com.cn/moneyflow/?stockName=上证指数&symbol=sh000001&stockSymb ...

  2. Mac 上 brew 安装Tomcat

    首先保证brew命令能够正常使用: 搜索tomcat是否存在:brew search tomcat 安装tomcat:brew install tomcat 检查是否安装成功:catalina -h ...

  3. There is insufficient memory for the Java Runtime Environment to continue.

    There is insufficient memory for the Java Runtime Environment to continue.

  4. MVC框架与增强

    一.什么是MVC MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑.数据.界面显示 ...

  5. 关于单片机的RAM

    一块RAM 分为了 堆 和 栈   名词而已,知道就可以了, 各种内存溢出问题: 全局数组访问越界 出现的问题:直接重启,或者死机 解决办法 :  额,写好自己的程序吧!!!!!!! 函数的局部变量过 ...

  6. type of的返回值有哪些

    typeof 10; // number typeof 'time'; //string typeof undefined; // undefined typeof null; // object t ...

  7. %lld 和 %I64d

    在Linux下输出long long 类型的是 printf("%lld", a); 在Windows下输出是 printf("%I64d", a); xxy学 ...

  8. 【题解】洛谷 P1083 借教室

    目录 题目 思路 \(Code\) 题目 P1083 借教室 思路 线段树.需要的操作为区间修改,区间查询.维护每个区间的最小值就好. \(Code\) #include<iostream> ...

  9. 2019 SDN上机第七次作业

    1.补充并运行basic /* -*- P4_16 -*- */ #include <core.p4> #include <v1model.p4> const bit<1 ...

  10. 【Beta】Scrum meeting 7

    目录 写在前面 进度情况 任务进度表 Beta-1阶段燃尽图 遇到的困难 照片 commit截图记录 后端代码仓库 技术博客 写在前面 例会时间:5.11 22:30-22:50 例会地点:微信群语音 ...