\u81f3\u6b64\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u6307\u4ee4\u63a7\u5236\u542f\u52a8\u505c\u6b62<\/p>\n
\/etc\/init.d\/nginx start\r\n\/etc\/init.d\/nginx stop<\/pre>\n\u4e0a\u9762\u7684\u65b9\u6cd5\u5b8c\u6210\u4e86\u7528\u811a\u672c\u7ba1\u7406nginx\u670d\u52a1\u7684\u529f\u80fd\uff0c\u4f46\u662f\u8fd8\u662f\u4e0d\u592a\u65b9\u4fbf\u3002<\/p>\n
\u5148\u5c06nginx\u670d\u52a1\u52a0\u5165chkconfig\u7ba1\u7406\u5217\u8868\uff1a<\/p>\n
[root@localhost ~]# chkconfig --add \/etc\/init.d\/nginx<\/pre>\n\u52a0\u5b8c\u8fd9\u4e2a\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528service\u5bf9nginx\u8fdb\u884c\u542f\u52a8\uff0c\u91cd\u542f\u7b49\u64cd\u4f5c\u4e86\u3002<\/p>\n
service nginx start\r\nservice nginx stop\r\nservice nginx restart<\/pre>\n\u6700\u540e\u8bbe\u7f6e\u5f00\u673a\u81ea\u52a8\u542f\u52a8<\/p>\n
[root@localhost ~]# chkconfig nginx on<\/pre>\n\r\n#!\/bin\/sh\r\n#\r\n# nginx - this script starts and stops the nginx daemon\r\n#\r\n# chkconfig: - 85 15\r\n# description: NGINX is an HTTP(S) server, HTTP(S) reverse \\\r\n# proxy and IMAP\/POP3 proxy server\r\n# processname: nginx\r\n# config: \/etc\/nginx\/nginx.conf\r\n# config: \/etc\/sysconfig\/nginx\r\n# pidfile: \/var\/run\/nginx.pid\r\n# Source function library.\r\n. \/etc\/rc.d\/init.d\/functions\r\n# Source networking configuration.\r\n. \/etc\/sysconfig\/network\r\n# Check that networking is up.\r\n[ \"$NETWORKING\" = \"no\" ] && exit 0\r\nnginx=\"\/usr\/sbin\/nginx\"\r\nprog=$(basename $nginx)\r\nNGINX_CONF_FILE=\"\/etc\/nginx\/nginx.conf\"\r\n[ -f \/etc\/sysconfig\/nginx ] && . \/etc\/sysconfig\/nginx\r\nlockfile=\/var\/lock\/subsys\/nginx\r\nmake_dirs() {\r\n # make required directories\r\n user=`$nginx -V 2>&1 | grep \"configure arguments:.*--user=\" | sed 's\/[^*]*--user=\\([^ ]*\\).*\/\\1\/g' -`\r\n if [ -n \"$user\" ]; then\r\n if [ -z \"`grep $user \/etc\/passwd`\" ]; then\r\n useradd -M -s \/bin\/nologin $user\r\n fi\r\n options=`$nginx -V 2>&1 | grep 'configure arguments:'`\r\n for opt in $options; do\r\n if [ `echo $opt | grep '.*-temp-path'` ]; then\r\n value=`echo $opt | cut -d \"=\" -f 2`\r\n if [ ! -d \"$value\" ]; then\r\n # echo \"creating\" $value\r\n mkdir -p $value && chown -R $user $value\r\n fi\r\n fi\r\n done\r\n fi\r\n}\r\nstart() {\r\n [ -x $nginx ] || exit 5\r\n [ -f $NGINX_CONF_FILE ] || exit 6\r\n make_dirs\r\n echo -n $\"Starting $prog: \"\r\n daemon $nginx -c $NGINX_CONF_FILE\r\n retval=$?\r\n echo\r\n [ $retval -eq 0 ] && touch $lockfile\r\n return $retval\r\n}\r\nstop() {\r\n echo -n $\"Stopping $prog: \"\r\n killproc $prog -QUIT\r\n retval=$?\r\n echo\r\n [ $retval -eq 0 ] && rm -f $lockfile\r\n return $retval\r\n}\r\nrestart() {\r\n configtest || return $?\r\n stop\r\n sleep 1\r\n start\r\n}\r\nreload() {\r\n configtest || return $?\r\n echo -n $\"Reloading $prog: \"\r\n killproc $prog -HUP\r\n retval=$?\r\n echo\r\n}\r\nforce_reload() {\r\n restart\r\n}\r\nconfigtest() {\r\n $nginx -t -c $NGINX_CONF_FILE\r\n}\r\nrh_status() {\r\n status $prog\r\n}\r\nrh_status_q() {\r\n rh_status >\/dev\/null 2>&1\r\n}\r\ncase \"$1\" in\r\n start)\r\n rh_status_q && exit 0\r\n $1\r\n ;;\r\n stop)\r\n rh_status_q || exit 0\r\n $1\r\n ;;\r\n restart|configtest)\r\n $1\r\n ;;\r\n reload)\r\n rh_status_q || exit 7\r\n $1\r\n ;;\r\n force-reload)\r\n force_reload\r\n ;;\r\n status)\r\n rh_status\r\n ;;\r\n condrestart|try-restart)\r\n rh_status_q || exit 0\r\n ;;\r\n *)\r\n echo $\"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}\"\r\n exit 2\r\nesac<\/pre>\n\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8eNginx\u8bbe\u7f6e\u6210\u670d\u52a1\u5e76\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5728\/etc\/init.d\u4e0b\u521b\u5efa\u6587\u4ef6nginx [root@localhost ~]# vim \/etc\/ini […]<\/p>\n","protected":false},"author":668,"featured_media":200669,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-235119","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=235119"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235119\/revisions"}],"predecessor-version":[{"id":235123,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/235119\/revisions\/235123"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/200669"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=235119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=235119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=235119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}