Make the Nginx service and start the CentOS boot to start the Ubuntu boot setup nginx boot

Source: Internet
Author: User
[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:--15# Description:ngin X is a high-performance web and proxy server.# it had a lot of features, but it's not for everyone.# PROCESSN ame:nginx# pidfile:/var/run/nginx.pid# config:/usr/local/nginx/conf/nginx.conf#nginx program path nginxd=/usr/sbin/nginx# Nginx configuration file path nginx_c/nginx/nginx.conf#nginx PID file path, can be found in Nginx configuration file 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 are 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 E   Cho-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.re    Load () {echo-n $ "reloading $prog:" #kill-hup ' cat ${nginx_pid} ' Killproc $nginxd-hup retval=$? echo}# See how we were Called.case "$" 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

The above describes the nginx into a service and start-up, including Nginx, boot-start aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.