﻿{"id":836,"date":"2012-08-04T10:43:12","date_gmt":"2012-08-04T02:43:12","guid":{"rendered":"http:\/\/notes.zerobox.org\/?p=836"},"modified":"2012-08-04T10:43:12","modified_gmt":"2012-08-04T02:43:12","slug":"nginx%e5%90%af%e5%8a%a8%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/zerobox.org\/notes\/836.html","title":{"rendered":"Nginx\u542f\u52a8\u811a\u672c"},"content":{"rendered":"<div>\n<div>\n<div>\n<div>\n<p>Nginx (&#8220;engine x&#8221;) \u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684HTTP\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u4e5f\u662f\u4e00\u4e2a IMAP\/POP3\/SMTP \u4ee3\u7406\u670d\u52a1\u5668\u3002\u56e0\u7a33\u5b9a\u6027\u3001\u4e30\u5bcc\u7684\u529f\u80fd\u3001\u4f4e\u8d44\u6e90\u6d88\u8017\u800c\u95fb\u540d\u3002<br \/>\n\u4f46Nginx\u672c\u8eab\u4e0d\u81ea\u5e26\u542f\u52a8\u811a\u672c\uff0c\u9700\u8981\u6211\u4eec\u624b\u52a8\u7f16\u5199\u4e00\u4efd\uff0c\u73b0\u5728\u7f51\u4e0a\u6240\u63d0\u4f9b\u7684\u5927\u591a\u6570\u811a\u672c\u90fd\u662f\u6709\u9488\u5bf9\u884c\u7684\uff0c\u53ef\u79fb\u690d\u6027\u5f88\u5dee\u3002<br \/>\n\u5927\u591a\u6570\u8fd9\u6837\u7684\u811a\u672c\u4f9d\u8d56\u4e8e\u7cfb\u7edf\u4e2dfunctions\u51fd\u6570\uff0c\u4f46\u8be5\u51fd\u6570\u4ec5\u5728\u4e2a\u522b\u7cfb\u7edf\u4e2d\u5b58\u5728\u3002<br \/>\n\u4e3a\u4e86\u4f7f\u811a\u672c\u66f4\u52a0\u901a\u7528\uff0c\u4ee5\u4e0b\u7f16\u5199\u7684\u811a\u672c\u53ef\u4ee5\u5f88\u8f7b\u677e\u7684\u79fb\u690d\u5230\u5404\u79cdUnix\u3001Linux\u7cfb\u7edf\u4e2d\uff0c\u540c\u65f6\u8fd8\u517c\u5bb9CentOS\u7684chkconfig\u529f\u80fd\u3002<br \/>\n\u6d4b\u8bd5\u8bc1\u660e\u65e0\u9700\u4fee\u6539\u5373\u53ef\u5728CentOS\u3001Ubuntu\u3001FreeBSD\u4e0a\u6d4b\u8bd5\u8fd0\u884c\u6b63\u5e38\u3002<br \/>\n\u811a\u672c\u7684\u601d\u8def\u662f\u901a\u8fc7nginx.pid\u6587\u4ef6\u6765\u5224\u65ad\u8fdb\u7a0b\u662f\u5426\u542f\u52a8\uff0c\u5f53\u7136\u5982\u679c\u4f60\u770b\u4e86http:\/\/manual.blog.51cto.com\/3300438\/932958\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7awk\u8fc7\u6ee4\u7aef\u53e3\u53f7\u5224\u65ad\u8fdb\u7a0b\u662f\u5426\u5f00\u542f\uff0c\u6548\u679c\u66f4\u597d\u3002<br \/>\n\u811a\u672c\u63d0\u4f9b\u4e86Nginx\u6240\u652f\u6301\u76846\u79cd\u8fdb\u7a0b\u7ba1\u7406\u4fe1\u53f7\u4e2d\u76844\u79cd\u542f\u52a8\u7528\u63a7\u5236\u4fe1\u53f7\uff0c\u540c\u65f6\u989d\u5916\u9644\u4ef6\u4e86\u4e00\u4e2a\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u7684\u529f\u80fd\u3002<br \/>\n\u811a\u672c\u5168\u6587\u5982\u4e0b\uff1a[root@centos6 ~] cat \/etc\/init.d\/nginx<\/p>\n<ol>\n<li>#!\/bin\/sh<\/li>\n<li>#<\/li>\n<li>#\u00a0Startup\u00a0script\u00a0for\u00a0the\u00a0Nginx<\/li>\n<li>#\u00a0chkconfig:\u00a0&#8211;\u00a088\u00a063<\/li>\n<li>#\u00a0description:\u00a0Nginx\u00a0is\u00a0a\u00a0free,open-source,high-performance\u00a0HTTP\u00a0Server\u00a0and\u00a0reverse\u00a0proxy.<\/li>\n<li>#\u00a0program:\/usr\/local\/nginx\/sbin\/nginx<\/li>\n<li>#\u00a0config:\/usr\/local\/nginx\/conf\/nginx.conf<\/li>\n<li>#\u00a0pidfile:\/usr\/local\/nginx\/logs\/nginx.pid<\/li>\n<li><\/li>\n<li>#\u00a0Synopsis:<\/li>\n<li>#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0nginx\u00a0[&#8211;help]\u00a0[&#8211;version]\u00a0{start|stop|restart|reload|status|update}<\/li>\n<li><\/li>\n<li><\/li>\n<li>#\u00a0Define\u00a0variable<\/li>\n<li>nginx=\/usr\/local\/nginx\/sbin\/nginx<\/li>\n<li>pidfile=\/usr\/local\/nginx\/logs\/nginx.pid<\/li>\n<li>PROGRAM=`basename\u00a0$0`<\/li>\n<li>VERSION=1.0<\/li>\n<li>#\u00a0Functions<\/li>\n<li>usage(){<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Usage:\u00a0$PROGRAM\u00a0[&#8211;help]\u00a0[&#8211;version]\u00a0{start|stop|restart|reload|status|update}&#8221;<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>version(){<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Version:$VERSION&#8221;<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>start(){<\/li>\n<li>if\u00a0[\u00a0-e\u00a0$pidfile\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Nginx\u00a0already\u00a0running&#8230;&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;Starting\u00a0Nginx:\\t\\t\\t\\t\\t\\t\\t\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\/usr\/local\/nginx\/sbin\/nginx<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;[\u00a0\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\033[0;32mOK\\033[0m\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8221;\u00a0]\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\r&#8221;<\/li>\n<li>fi<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>stop(){<\/li>\n<li>if\u00a0[\u00a0-e\u00a0$pidfile\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;Stopping\u00a0Nginx:\\t\\t\\t\\t\\t\\t\\t\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0kill\u00a0-QUIT\u00a0`cat\u00a0${pidfile}`<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;[\u00a0\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\033[0;32mOK\\033[0m\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8221;\u00a0]\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\r&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Nginx\u00a0already\u00a0stopped&#8230;&#8221;<\/li>\n<li>fi<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>reload(){<\/li>\n<li>if\u00a0[\u00a0-e\u00a0$pidfile\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;Reloading\u00a0Nginx:\\t\\t\\t\\t\\t\\t\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0kill\u00a0-HUP\u00a0`cat\u00a0${pidfile}`<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;[\u00a0\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\033[0;32mOK\\033[0m\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8221;\u00a0]\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\r&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Nginx\u00a0is\u00a0not\u00a0running&#8230;&#8221;<\/li>\n<li>fi<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>status(){<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0if\u00a0[\u00a0-e\u00a0$pidfile\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0PID=`cat\u00a0$pidfile`<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0\u00a0&#8220;Nginx\u00a0(pid\u00a0$PID)\u00a0is\u00a0running&#8230;&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo\u00a0\u00a0&#8220;Nginx\u00a0is\u00a0stopped&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0fi<\/li>\n<li>}<\/li>\n<li><\/li>\n<li>update(){<\/li>\n<li>if\u00a0[\u00a0-e\u00a0$pidfile\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;Updateing\u00a0Nginx:\\t\\t\\t\\t\\t\\t\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0kill\u00a0-USR2\u00a0`cat\u00a0${pidfile}`<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;[\u00a0\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\033[0;32mOK\\033[0m\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8221;\u00a0]\\c&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0-e\u00a0&#8220;\\r&#8221;<\/li>\n<li>\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0echo\u00a0&#8220;Nginx\u00a0is\u00a0not\u00a0running&#8230;&#8221;<\/li>\n<li>fi<\/li>\n<li>}<\/li>\n<li>if\u00a0[\u00a0$#\u00a0-gt\u00a00\u00a0]<\/li>\n<li>\u00a0\u00a0\u00a0then<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0case\u00a0$1\u00a0in<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0start)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0start<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0stop)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0stop<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0restart)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0stop<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0start<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0reload)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0reload<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0status)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0status<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0update)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0update<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211;help)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0usage<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211;version)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0version<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0*)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0usage<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0esac<\/li>\n<li>\u00a0\u00a0\u00a0else<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0usage<\/li>\n<li>fi<\/li>\n<\/ol>\n<p>\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u4f7f\u7528\u7684\u662fCentOS\u6216RedHat\u7684\u7cfb\u7edf\uff0c\u53ef\u4ee5\u901a\u8fc7chkconfig\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5f00\u673a\u542f\u52a8\u9879\u3002<br \/>\n[root@centos6 ~] chkconfig\u00a0 &#8211;add\u00a0 nginx<br \/>\n[root@centos6 ~] chkconfig\u00a0 nginx\u00a0 on<br \/>\n\u811a\u672c\u8fd0\u884c\u6548\u679c\u5982\u56fe\uff1a<\/p>\n<p><a href=\"http:\/\/img1.51cto.com\/attachment\/201207\/122058303.png\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/attachment\/201207\/122058303.png\" alt=\"\u4e01\u4e01\u5386\u9669\" width=\"650\" border=\"0\" \/><\/a><a href=\"http:\/\/img1.51cto.com\/attachment\/201207\/122058956.png\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/attachment\/201207\/122058956.png\" alt=\"\u4e01\u4e01\u5386\u9669\" width=\"650\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u672c\u6587\u51fa\u81ea \u201c<a href=\"http:\/\/manual.blog.51cto.com\/\">\u4e01\u4e01\u5386\u9669<\/a>\u201d \u535a\u5ba2\uff0c\u8bf7\u52a1\u5fc5\u4fdd\u7559\u6b64\u51fa\u5904<a href=\"http:\/\/manual.blog.51cto.com\/3300438\/948874\">http:\/\/manual.blog.51cto.com\/3300438\/948874<\/a><\/p>\n<\/div>\n<div>\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\" valign=\"middle\" width=\"11%\" height=\"43\"><img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/images\/share\/ssk.png\" alt=\"\u5206\u4eab\u81f3\" \/><\/td>\n<td align=\"left\" valign=\"top\" width=\"77%\">\n<div id=\"bdshare\"><em title=\"\u5206\u4eab\u523051CTO\u5fae\u535a\"><\/em>\u66f4\u591a<a title=\"\u7d2f\u8ba1\u5206\u4eab2\u6b21\" href=\"http:\/\/manual.blog.51cto.com\/#\">2<\/a><\/div>\n<\/td>\n<td align=\"right\" valign=\"middle\" width=\"12%\"><a title=\"\u4e00\u952e\u6536\u85cf\uff0c\u968f\u65f6\u67e5\u770b\uff0c\u5206\u4eab\u597d\u53cb\uff01\" href=\"http:\/\/manual.blog.51cto.com\/3300438\/948874\"><img decoding=\"async\" src=\"http:\/\/home.51cto.com\/public\/themes\/blue\/images\/favorite_add_small.gif\" alt=\"\u4e00\u952e\u6536\u85cf\uff0c\u968f\u65f6\u67e5\u770b\uff0c\u5206\u4eab\u597d\u53cb\uff01\" border=\"0\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table width=\"720\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"right\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/phpanddb.blog.51cto.com\/image\/skin\/25\/icon01.png\" alt=\"\" width=\"15\" height=\"16\" \/>\u00a0<a id=\"favourer\">linuxsong\u3001liuliu991\u3001\u716e\u9152\u54c1\u8336<\/a><\/td>\n<td align=\"left\" width=\"70\">\n<div id=\"favourdiv\">4\u4eba<\/div>\n<\/td>\n<td align=\"left\" width=\"60\">\u4e86\u8fd9\u7bc7\u6587\u7ae0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div>\u7c7b\u522b\uff1a<a href=\"http:\/\/manual.blog.51cto.com\/3300438\/d-2\">Linux\u670d\u52a1<\/a>\u2506<a>\u6280\u672f\u5708<\/a>(0)\u2506\u9605\u8bfb(166)\u2506\u8bc4\u8bba(5) \u2506\u00a0<a href=\"http:\/\/manual.blog.51cto.com\/#\">\u63a8\u9001\u5230\u6280\u672f\u5708<\/a>\u2506<a href=\"http:\/\/manual.blog.51cto.com\/\">\u8fd4\u56de\u9996\u9875<\/a><\/div>\n<div>\u4e0a\u4e00\u7bc7\u00a0<a title=\"Nginx\u4e4b\u5f00\u95e8\u89c1\u5c71\" href=\"http:\/\/manual.blog.51cto.com\/3300438\/948204\">Nginx\u4e4b\u5f00\u95e8\u89c1\u5c71<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<div><a name=\"replay\"><\/a><\/p>\n<h2>\u6587\u7ae0\u8bc4\u8bba<\/h2>\n<\/div>\n<div id=\"artcomment\">\n<div><\/div>\n<p><a name=\"499314\"><\/a><\/p>\n<div id=\"itcommentid0\">\n<div>\n<div><label>[1\u697c]\u00a0\u00a0\u00a0\u00a0<img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/image\/skin\/reply.gif\" alt=\"\" \/>\u00a0\u00a0<a href=\"http:\/\/cwtea.blog.51cto.com\/\" target=\"_blank\"><strong>\u716e\u9152\u54c1\u8336<\/strong><\/a><\/label><label>\u00a0<a href=\"http:\/\/manual.blog.51cto.com\/#\">\u56de\u590d<\/a><\/label><\/div>\n<\/div>\n<div align=\"right\">2012-08-01 10:32:30<\/div>\n<div>\u5199\u7684\u975e\u5e38Nice\uff0c\u5b66\u4e60\u4e86 ,\u8fd9\u4e2a\u7248\u672c\u663e\u793a\u7684\u6709\u70b9\u4e0d\u7528\u5fc3\u3002<\/div>\n<\/div>\n<p><a name=\"499390\"><\/a><\/p>\n<div id=\"itcommentid1\">\n<div>\n<div><label>[2\u697c]\u00a0\u00a0\u00a0\u00a0<img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/image\/skin\/reply.gif\" alt=\"\" \/>\u00a0\u00a0<a href=\"http:\/\/song49.blog.51cto.com\/\" target=\"_blank\"><strong>linuxsong<\/strong><\/a><\/label><label>\u00a0<a href=\"http:\/\/manual.blog.51cto.com\/#\">\u56de\u590d<\/a><\/label><\/div>\n<\/div>\n<div align=\"right\">2012-08-01 14:33:58<\/div>\n<div>Very Nice\uff01<\/div>\n<\/div>\n<p><a name=\"499517\"><\/a><\/p>\n<div id=\"itcommentid2\">\n<div>\n<div><label>[3\u697c]\u00a0\u00a0\u00a0\u00a0<img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/image\/skin\/reply.gif\" alt=\"\" \/>\u00a0\u00a0<a href=\"http:\/\/renyudi.blog.51cto.com\/\" target=\"_blank\"><strong>xyrhdd<\/strong><\/a><\/label><label>\u00a0<a href=\"http:\/\/manual.blog.51cto.com\/#\">\u56de\u590d<\/a><\/label><\/div>\n<\/div>\n<div align=\"right\">2012-08-02 09:22:07<\/div>\n<div>\u4e0d\u9519\uff0c\u8fd9\u811a\u672c\u6bd4\u8f83\u76f4\u89c2\uff0c\u6536\u85cf\u5907\u7528\u4e86\uff01<\/div>\n<\/div>\n<p><a name=\"499530\"><\/a><\/p>\n<div id=\"itcommentid3\">\n<div>\n<div><label>[4\u697c]\u00a0\u00a0\u00a0\u00a0<img decoding=\"async\" src=\"http:\/\/img1.51cto.com\/image\/skin\/reply.gif\" alt=\"\" \/>\u00a0\u00a0[\u533f\u540d]dym_cisco<\/label><label>\u00a0<a href=\"http:\/\/manual.blog.51cto.com\/#\">\u56de\u590d<\/a><\/label><\/div>\n<\/div>\n<div align=\"right\">2012-08-02 09:47:14<\/div>\n<div>\u901a\u8fc7rpm\u5305\u5b89\u88c5nginx\uff0c\u662f\u81ea\u5e26\u542f\u52a8\u811a\u672c\u7684\uff0c\u5728\/etc\/rc.d\/init.d\/\u76ee\u5f55\u4e0b\uff0c\u5c31\u6709nginx\u7684\u542f\u52a8\u76ee\u5f55\uff0c\u542f\u52a8\u811a\u672c\u5982\u4e0b\uff1a<br \/>\n#!\/bin\/sh<br \/>\n#<br \/>\n# nginx \u00a0 \u00a0 Startup script for nginx<br \/>\n#<br \/>\n# chkconfig: &#8211; 85 15<br \/>\n# processname: nginx<br \/>\n# config: \/etc\/nginx\/nginx.conf<br \/>\n# config: \/etc\/sysconfig\/nginx<br \/>\n# pidfile: \/var\/run\/nginx.pid<br \/>\n# description: nginx is a HTTP and reverse proxy server<br \/>\n#<br \/>\n### BEGIN INIT INFO<br \/>\n# Provides: nginx<br \/>\n# Required-Start: $local_fs $remote_fs $network<br \/>\n# Required-Stop: $local_fs $remote_fs $network<br \/>\n# Default-Start: 2 3 4 5<br \/>\n# Default-Stop: 0 1 6<br \/>\n# Short-Description: start and stop nginx<br \/>\n### END INIT INFO<\/p>\n<p># Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions<\/p>\n<p>if [ -f \/etc\/sysconfig\/nginx ]; then<br \/>\n. \/etc\/sysconfig\/nginx<br \/>\nfi<\/p>\n<p>prog=nginx<br \/>\nnginx=${NGINX-\/usr\/sbin\/nginx}<br \/>\nconffile=${CONFFILE-\/etc\/nginx\/nginx.conf}<br \/>\nlockfile=${LOCKFILE-\/var\/lock\/subsys\/nginx}<br \/>\npidfile=${PIDFILE-\/var\/run\/nginx.pid}<br \/>\nSLEEPMSEC=100000<br \/>\nRETVAL=0<\/p>\n<p>start() {<br \/>\necho -n $&#8221;Starting $prog: &#8221;<\/p>\n<p>daemon &#8211;pidfile=${pidfile} ${nginx} -c ${conffile}<br \/>\nRETVAL=$?<br \/>\necho<br \/>\n[ $RETVAL = 0 ] &amp;&amp; touch ${lockfile}<br \/>\nreturn $RETVAL<br \/>\n}<\/p>\n<p>stop() {<br \/>\necho -n $&#8221;Stopping $prog: &#8221;<br \/>\nkillproc -p ${pidfile} ${prog}<br \/>\nRETVAL=$?<br \/>\necho<br \/>\n[ $RETVAL = 0 ] &amp;&amp; rm -f ${lockfile} ${pidfile}<br \/>\n}<\/p>\n<p>reload() {<br \/>\necho -n $&#8221;Reloading $prog: &#8221;<br \/>\nkillproc -p ${pidfile} ${prog} -HUP<br \/>\nRETVAL=$?<br \/>\necho<br \/>\n}<\/p>\n<p>upgrade() {<br \/>\noldbinpidfile=${pidfile}.oldbin<\/p>\n<p>configtest -q || return 6<br \/>\necho -n $&#8221;Staring new master $prog: &#8221;<br \/>\nkillproc -p ${pidfile} ${prog} -USR2<br \/>\nRETVAL=$?<br \/>\necho<br \/>\n\/bin\/usleep $SLEEPMSEC<br \/>\nif [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then<br \/>\necho -n $&#8221;Graceful shutdown of old $prog: &#8221;<br \/>\nkillproc -p ${oldbinpidfile} ${prog} -QUIT<br \/>\nRETVAL=$?<br \/>\necho<br \/>\nelse<br \/>\necho $&#8221;Upgrade failed!&#8221;<br \/>\nreturn 1<br \/>\nfi<br \/>\n}<\/p>\n<p>configtest() {<br \/>\nif [ &#8220;$#&#8221; -ne 0 ] ; then<br \/>\ncase &#8220;$1&#8221; in<br \/>\n-q)<br \/>\nFLAG=$1<br \/>\n;;<br \/>\n*)<br \/>\n;;<br \/>\nesac<br \/>\nshift<br \/>\nfi<br \/>\n${nginx} -t -c ${conffile} $FLAG<br \/>\nRETVAL=$?<br \/>\nreturn $RETVAL<br \/>\n}<\/p>\n<p>rh_status() {<br \/>\nstatus -p ${pidfile} ${nginx}<br \/>\n}<\/p>\n<p># See how we were called.<br \/>\ncase &#8220;$1&#8243; in<br \/>\nstart)<br \/>\nrh_status &gt;\/dev\/null 2&gt;&amp;1 &amp;&amp; exit 0<br \/>\nstart<br \/>\n;;<br \/>\nstop)<br \/>\nstop<br \/>\n;;<br \/>\nstatus)<br \/>\nrh_status<br \/>\nRETVAL=$?<br \/>\n;;<br \/>\nrestart)<br \/>\nconfigtest -q || exit $RETVAL<br \/>\nstop<br \/>\nstart<br \/>\n;;<br \/>\nupgrade)<br \/>\nupgrade<br \/>\n;;<br \/>\ncondrestart|try-restart)<br \/>\nif rh_status &gt;\/dev\/null 2&gt;&amp;1; then<br \/>\nstop<br \/>\nstart<br \/>\nfi<br \/>\n;;<br \/>\nforce-reload|reload)<br \/>\nreload<br \/>\n;;<br \/>\nconfigtest)<br \/>\nconfigtest<br \/>\n;;<br \/>\n*)<br \/>\necho $&#8221;Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}&#8221;<br \/>\nRETVAL=2<br \/>\nesac<\/p>\n<p>exit $RETVAL<\/p><\/div>\n<div><\/div>\n<div>\u6765\u6e90:<a href=\"http:\/\/manual.blog.51cto.com\/3300438\/948874\">http:\/\/manual.blog.51cto.com\/3300438\/948874<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Nginx (&#8220;engine x&#8221;) \u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684HT &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/zerobox.org\/notes\/836.html\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[203],"class_list":["post-836","post","type-post","status-publish","format-standard","hentry","tag-nginx"],"views":1815,"_links":{"self":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/comments?post=836"}],"version-history":[{"count":0,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/836\/revisions"}],"wp:attachment":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/media?parent=836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/categories?post=836"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/tags?post=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}