Nginx配置成CentOS服务
前言
源码编译安装Nginx后,需要配置开机自启,顺便想要通过服务化进行操作nginx的运行,因此编写了本教程记录个人的解决过程。
https://blog.youkuaiyun.com/RisenMyth/article/details/104589071
编写Shell脚本
这里的NGINX_PATH
变量请填写自己的nginx可执行文件路径。
#!/bin/sh
# nginx
# chkconfig: 2345 55 25
# description: nginx service shell.
NGINX_PATH=/opt/nginx/sbin/nginx
SERVER_PID=""
checkPid() {
SERVER_PID=$(ps -ef | grep nginx | grep master | grep -v grep | awk '{ print $2 }')