您好,欢迎访问一九零五行业门户网

将nginx做成服务并开机启动 centos 开机启动 ubuntu 开机启动 设置nginx开机启

[root@localhost ~]#vi /etc/init.d/nginx #新建文件
#!/bin/bash# nginx startup script for the nginx http server# it is v.0.0.2 version.# chkconfig: - 85 15# description: nginx is a high-performance web and proxy server.# it has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.conf#nginx程序路径nginxd=/usr/sbin/nginx#nginx配置文件路径nginx_c/nginx/nginx.conf#nginx pid文件的路径,可以在nginx的配置文件中找到nginx_pid=/var/run/nginx/nginx.pidretval=0prog=nginx# source function library.. /etc/rc.d/init.d/functions# source networking configuration.. /etc/sysconfig/network# check that networking is up.[ ${networking} = no ] && exit 0[ -x $nginxd ] || exit 0# start nginx daemons functions.start() {if [ -e $nginx_pid ];then echo nginx already running.... exit 1fi echo -n $starting $prog: daemon $nginxd -c ${nginx_config} retval=$? echo [ $retval = 0 ] && touch /var/lock/subsys/nginx return $retval}# stop nginx daemons functions.stop() { echo -n $stopping $prog: killproc $nginxd retval=$? echo [ $retval = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() { echo -n $reloading $prog: #kill -hup `cat ${nginx_pid}` killproc $nginxd -hup retval=$? echo}# see how we were called.case $1 instart) start ;;stop) stop ;;reload) reload ;;restart) stop start ;;status) status $prog retval=$? ;;*) echo $usage: $prog {start|stop|restart|reload|status|help} exit 1esacexit $retval
[root@localhost ~]#chmod +x /etc/init.d/nginx #加执行权限[root@localhost ~]#chkconfig --add nginx #将nginx做成服务[root@localhost ~]# chkconfig --list |grep nginxnginx 0:off 1:off 2:off 3:off 4:off 5:off 6:off[root@localhost ~]# chkconfig nginx on #将nginx做成开机启动[root@localhost ~]# chkconfig --list |grep nginxnginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
以上就介绍了将nginx做成服务并开机启动,包括了nginx,开机启动方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息