添加Nginx作为系统服务
来源:互联网 发布:mac foxmail 邮件备份 编辑:程序博客网 时间:2024/05/17 02:27
前言
创建一个脚本,该脚本将改变nginx
守护进程,让nginx
以系统服务的形式启动,守护进程以后将由标准的命令控制且在系统启动时自动启动。
System V脚本
大多数基于linux的操作系统,使用的是System-V风格的init守护进程,启动进程由init进程管理。
守护进程遵循运行级别的原则(run level),系统运行级别表示当前计算机状态。
关闭系统:
[root@localhost ~]# telinit 0
重启系统:
[root@localhost ~]# telinit 6
对于每一个运行级别的转换都会有一组服务被执行,系统停止时它的运行级别为0,一旦开启将转换到默认启动级别,系统默认启动级别是在etc/inittab
文件下配置的。
为nginx建立init脚本
目录/etc/init.d
实际上是/etc/rc.d/init.d
的符号链接,因此在/etc/init.d目录下新建文件nginx
(需要root权限):
[root@localhost rc.d]# vi /etc/init.d/nginx
脚本内容如下:
#!/bin/bash
# chkconfig: - 85 15
#description: Nginx is a World Wide Web server.
#processname: nginxnginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx/conf/nginx.conf
case $1 in
start)
echo -n “Starting Nginx”
$nginx -c $conf
echo ” done”
;;
stop)
echo -n “Stopping Nginx”
killall -9 nginx
echo ” done”
;;
test)
$nginx -t -c $conf
;;
reload)
echo -n “Reloading Nginx”
ps auxww | grep nginx | grep master | awk ‘{print $2}’ | xargs kill -HUP
echo ” done”
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep nginx
;;
*)
echo -n “Usage: $0 {start|restart|reload|stop|test|show}”
;;
esac
安装nginx的init脚本
授予该脚本可执行权限:
[root@localhost rc.d]# chmod +x /etc/init.d/nginx
然后就可以开启nginx:
[root@localhost init.d]# service nginx start
或:
[root@localhost init.d]# /etc/init.d/nginx start
原地址链接:http://blog.csdn.net/zsl10/article/details/52190206
- 添加nginx作为系统服务
- 添加Nginx作为系统服务
- nginx 作为系统服务
- nginx添加为系统服务
- 添加nginx为系统服务
- windows系统下将nginx作为系统服务启动
- 将nginx添加为系统服务
- 添加nginx到系统服务注意事项
- 搬瓦工nginx添加到系统服务
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- CentOS6.3添加nginx php-fpm系统服务详细说明
- CentOS6.3添加nginx系统服务详细说明
- 在windows下将Nginx添加为系统服务
- linux 添加nginx服务
- Linux添加nginx为系统服务(service nginx status/start/stop/restart)
- Windows下Nginx作为服务启动
- Java面试题整理
- Buffer vs. Cache
- 解耦与分离 —— 面向切面编程(AOP)
- 图片伪装病毒的奇淫技巧
- 系统日志管理那点事
- 添加Nginx作为系统服务
- 查看tensorflow ckpt文件中的变量名和对应值
- 【009】Java语言(环境变量配置-临时配置方法)
- phpcms v9.6.0版本getshell测试
- 快捷键大全-私人收藏
- [leetcode]664. Strange Printer
- 常见排序算法(时,空)复杂度总结及稳定性分析
- CentOS7.3安装部署wordpress
- SGISTL源码探究-vector容器(上)