nginx init script for centos

From WebHostingNeeds.com
Jump to: navigation, search
wget https://webhostingneeds.com/yujin/nginx
mv nginx /etc/rc.d/init.d/
chmod 755 /etc/rc.d/init.d/nginx
/etc/rc.d/init.d/nginx status

Now add nginx to chkconfig and make it start on server boot

chkconfig --add nginx
chkconfig nginx on

Now it should list as service that will run on level 3 (non gui, multi user mode).

[[email protected] ~]# chkconfig --list|grep 3:on
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
irqbalance      0:off   1:off   2:on    3:on    4:on    5:on    6:off
lighttpd        0:off   1:off   2:on    3:on    4:on    5:on    6:off
lighttpd2       0:off   1:off   2:on    3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
nginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off
pure-ftpd       0:off   1:off   2:on    3:on    4:on    5:on    6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
yum-updatesd    0:off   1:off   2:on    3:on    4:on    5:on    6:off
[[email protected] ~]#


Now to start/stop nginx

service nginx start
service nginx stop
service nginx status




nginx