[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.