starfish29

一、问题描述:

  无法用service命令启动nginx

  

二、问题分析:

  /etc/init.d/目录下缺少nginx默认启动脚本

三、问题解决:

  在/etc/init.d/路径下添加脚本文件,名称为nginx,并添加文件可执行权限:

  

 

 

  修改nginx启动脚本文件:  

#!/bin/bash
#Startup script for the nginx Web Server
#chkconfig: 2345 85 15
nginx=/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
echo "Success."
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk \'{print $2}\' | xargs kill -HUP
echo " done."
;;
restart)
$nginx -s reload
echo "reload done."
;;
*)
echo "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac

   

四、问题验证:

  

分类:

技术点:

相关文章:

  • 2021-10-01
  • 2021-10-16
  • 2021-10-25
  • 2021-10-15
  • 2021-05-24
  • 2021-12-29
  • 2022-01-08
猜你喜欢
  • 2021-10-16
  • 2021-11-17
  • 2021-12-01
  • 2022-02-13
相关资源
相似解决方案