一、问题描述:
无法用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
四、问题验证: