{"id":33209,"date":"2022-11-26T12:36:36","date_gmt":"2024-02-19T01:50:05","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/"},"modified":"2024-04-29T02:33:37","modified_gmt":"2024-04-28T18:33:37","slug":"%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/","title":{"rendered":"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b"},"content":{"rendered":"<h1>\u6a31\u82b1\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668<\/h1>\n<p>\uff08\u8ffd\u8a18\uff1a2016-07-09\uff09<\/p>\n<p>\u5982\u679c\u6309\u7167\u6b64\u5904\u7684\u65b9\u6cd5\u5b89\u88c5Nginx\uff0c<br \/>\n\u53d1\u73b0openssl1.0.2\u5b58\u5728\u6f0f\u6d1e\uff08CVE-2016-2107\uff0cCVE-2016-2105\uff0cCVE-2016-2106\uff0cCVE-2016-2109\uff0cCVE-2016-2176\uff09\uff0c<br \/>\n\u5efa\u8bae\u5347\u7ea7openssl\u7684\u7248\u672c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u662f\u5728\u8fd9\u91cc\u5b89\u88c5Nginx\u6216\u8005\u51c6\u5907\u5b89\u88c5Nginx\u7684\u4eba\uff0c\u8bf7\u53c2\u8003\u8fd9\u91cc\u3002<\/p>\n<h2>\u6a31\u82b1VPS\u7684\u60c5\u51b5<\/h2>\n<p>\u3053\u3053\u304b\u3053\u3053\u306e\u521d\u671f\u8a2d\u5b9a\u304c\u7d42\u308f\u3063\u3066\u308b\u72b6\u614b\uff0e<br \/>\nOS\u306f\u6a19\u6e96\u306eCentOS 6.7<\/p>\n<p>\u786e\u8ba4 Sakura VPS \u4e0a\u5b89\u88c5\u7684\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">cat<\/span> \/etc\/redhat-release\r\nCentOS release 6.7 <span class=\"o\">(<\/span>Final<span class=\"o\">)<\/span>\r\n<\/code><\/pre>\n<h2>Nginx\u7684\u6784\u5efa<\/h2>\n<p>\u6211\u7acb\u523b\u5f00\u59cb\u6784\u5efaNginx\u3002<br \/>\n\u4ee5\u4e0b\u5047\u8bbe\u5df2\u7ecf\u8fde\u63a5\u5230\u6a31\u82b1VPS\u5e76\u901a\u8fc7SSH\u8fdb\u884c\u64cd\u4f5c\u3002<br \/>\n\u6211\u60f3\u5c1d\u8bd5\u4f7f\u7528yum\u5b89\u88c5\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>yum info nginx\r\n<\/code><\/pre>\n<p>\u5c1d\u8bd5\u4e00\u4e0b\u8fd9\u4e2a\u7248\u672c\u592a\u65e7\u4e86\uff0c\u4f60\u662f\u5728\u9a97\u4eba\u5417\uff1f\u6240\u4ee5\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u6dfb\u52a0\u4ee3\u7801\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>rpm <span class=\"nt\">-ivh<\/span> http:\/\/nginx.org\/packages\/centos\/6\/noarch\/RPMS\/nginx-release-centos-6-0.el6.ngx.noarch.rpm\r\n<\/code><\/pre>\n<p>\u6211\u672c\u4ee5\u4e3a\u8fd9\u6837\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>yum <span class=\"nt\">-y<\/span> <span class=\"nb\">install <\/span>nginx\r\n<span class=\"nv\">$ <\/span>nginx <span class=\"nt\">-v<\/span>\r\nnginx version: nginx\/1.8.1\r\n<\/code><\/pre>\n<p>\u5b89\u88c5\u7684\u662fNginx 1.8\u7248\u672c\uff0c\u6211\u60f3\u8981\u7684\u662f1.9\u7248\u672c\uff0c\u6240\u4ee5\u4e0d\u53ef\u4ee5\u3002(\u5982\u679c1.8\u7248\u672c\u4e5f\u53ef\u4ee5\u7684\u8bdd\uff0c\u53ef\u4ee5\u63a5\u53d7)<\/p>\n<h2>\u4ece\u6e90\u4ee3\u7801\u4e2d\u7f16\u8bd1\u548c\u5b89\u88c5Nginx\u3002<\/h2>\n<p>\u5982\u679c\u4e4b\u524d\u5b89\u88c5\u4e86nginx\u7684\u4eba\uff0c\u6267\u884cyum remove nginx<\/p>\n<p>\u9996\u5148\uff0c\u65e0\u8bba\u54ea\u4e2a\u90fd\u53ef\u4ee5\uff0c\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">mkdir<\/span> ~\/hoge\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">cd<\/span> ~\/hoge\r\n<\/code><\/pre>\n<h3>\u4e0b\u8f7d\u6e90\u4ee3\u7801<\/h3>\n<p>\u5728\u521b\u5efa\u7684\u76ee\u5f55\u4e2d\u4e0b\u8f7d\u6240\u9700\u7684\u6700\u65b0\u6e90\u4ee3\u7801\u3002<br \/>\n\u6240\u9700\u6e90\u4ee3\u7801\u7684\u4e3b\u9875\u5728\u8fd9\u91cc\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx-1.9\u7cfb http:\/\/nginx.org\/en\/download.html<\/ul>\n<\/li>\n<\/ul>\n<p>openssl-1.0.2\u7cfb https:\/\/www.openssl.org\/source\/<\/p>\n<p>pcre-8.3\u7cfb http:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/<\/p>\n<p>zlib-1.2\u7cfb http:\/\/zlib.net\/<\/p>\n<p>\u76ee\u524d\uff082016-03-03\uff09\u6700\u65b0\u7684\u662f\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx-1.9.12<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">openssl-1.0.2g<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">pcre-8.38<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">zlib-1.2.8<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">(\u7b46\u8005\u306fwget\u3060\u3051\u3069\u4ed6\u306e\u65b9\u6cd5\u3067\u3082ok)<\/ul>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>wget http:\/\/nginx.org\/download\/nginx-1.9.12.tar.gz\r\n<span class=\"nv\">$ <\/span>wget https:\/\/www.openssl.org\/source\/openssl-1.0.2g.tar.gz\r\n<span class=\"nv\">$ <\/span>wget http:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-8.38.tar.gz\r\n<span class=\"nv\">$ <\/span>wget http:\/\/zlib.net\/zlib-1.2.8.tar.gz\r\n<\/code><\/pre>\n<p>\u5982\u679c\u6709\u4efb\u4f55\u7591\u8651\u6216\u62c5\u5fc3\uff0c\u5c31\u8981\u786e\u4fdd\u8fdb\u884cMD5\u3001SHASUM\u7b49\u54c8\u5e0c\u503c\u7684\u6838\u5bf9\u3002<\/p>\n<h3>\u6e90\u4ee3\u7801\u5c55\u5f00<\/h3>\n<p>\u5982\u679c\u80fd\u591f\u8fdb\u884c\u5339\u914d\uff0c\u90a3\u5c31\u8fdb\u884c\u5c55\u5f00\u3002<br \/>\n\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b4\u4e2a\u547d\u4ee4\uff0c\u4f46\u662f\u2026<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">tar <\/span>zxvf nginx-1.9.12.tar.gz\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">tar <\/span>zxvf openssl-1.0.2g.tar.gz\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">tar <\/span>zxvf pcre-8.38.tar.gz\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">tar <\/span>zxvf zlib-1.2.8.tar.gz\r\n<\/code><\/pre>\n<p>\u4f9d\u9760shell\u4e00\u6b21\u5b8c\u6210\u4ee5\u4e0b\u5de5\u4f5c\u4f1a\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>find .\/ <span class=\"nt\">-type<\/span> f <span class=\"nt\">-name<\/span> <span class=\"s2\">\"*.tar.gz\"<\/span> <span class=\"nt\">-exec<\/span> <span class=\"nb\">tar <\/span>zxf <span class=\"o\">{}<\/span> <span class=\"se\">\\;<\/span>\r\n<\/code><\/pre>\n<p>\u66ab\u4e14\u6838\u5c0d\u4e00\u4e0b\u3002 .)<br \/>\nor<br \/>\n\u66ab\u6642\u78ba\u4fdd\uff0c\u6211\u8a18\u4e0b\u4f86\u4e86\u3002 , w\u01d2 le.)<\/p>\n<p>Note: Both options are commonly used to convey the meaning of &#8220;Just to make sure, I&#8217;ll double check.&#8221;<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">ls\r\n<\/span>nginx-1.9.12         openssl-1.0.2g.tar.gz\r\nnginx-1.9.12.tar.gz  pcre-8.38              zlib-1.2.8.tar.gz    zlib-1.2.8\r\nopenssl-1.0.2g       pcre-8.38.tar.gz\r\n<\/code><\/pre>\n<p>\u597d\u7684\u3002<\/p>\n<h3>\u6e90\u4ee3\u7801\u7684\u6784\u5efa\u548c\u5b89\u88c5<\/h3>\n<p>\u786e\u8ba4\u540e\uff0c\u5728Nginx\u7684\u6e90\u4ee3\u7801\u4e2d\u8fdb\u884c\u6784\u5efa\u548c\u5b89\u88c5\u3002<br \/>\n\u5b89\u88c5\u8def\u5f84\u4e3a \/usr\/local\/nginx \u53ca\u4ee5\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">cd <\/span>nginx-1.9.12\r\n<span class=\"nv\">$ <\/span>.\/configure <span class=\"nt\">--with-openssl<\/span><span class=\"o\">=<\/span>..\/openssl-1.0.2g\/ <span class=\"nt\">--with-http_ssl_module<\/span> <span class=\"nt\">--with-pcre<\/span><span class=\"o\">=<\/span>..\/pcre-8.38 <span class=\"nt\">--with-zlib<\/span><span class=\"o\">=<\/span>..\/zlib-1.2.8  <span class=\"nt\">--with-http_v2_module<\/span> <span class=\"nt\">--with-debug<\/span>\r\n<span class=\"nv\">$ <\/span>make\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>make <span class=\"nb\">install<\/span>\r\n<\/code><\/pre>\n<p>\u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u68c0\u67e5 configure \u51fd\u6570\u7684\u6bcf\u4e2a\u53c2\u6570\u7684\u540d\u79f0\u662f\u5426\u5339\u914d\u3002<\/p>\n<p>\u8fd9\u57fa\u672c\u4e0a\u5c31\u7ed3\u675f\u4e86\u3002<\/p>\n<p>\u786e\u8ba4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo<\/span> \/usr\/local\/nginx\/sbin\/nginx <span class=\"nt\">-v<\/span>\r\nnginx version: nginx\/1.9.12\r\n<\/code><\/pre>\n<p>\u597d\u7684\u3002<\/p>\n<p>\u6211\u542f\u52a8\u5e76\u786e\u8ba4\u4e00\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo<\/span> \/usr\/local\/nginx\/sbin\/nginx\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">tail<\/span> \/usr\/local\/nginx\/logs\/error.log\r\n2016\/03\/02 17:18:03 <span class=\"o\">[<\/span>notice] 3008#0: signal process started\r\n<\/code><\/pre>\n<p>\u597d\u7684\u3002\u5bf9\u4e8e\u5404\u79cd\u8bbe\u5b9a\uff0c\u60a8\u53ef\u4ee5\u4fee\u6539&#8221;\/usr\/local\/nginx\/conf\/nginx.conf&#8221;\u6587\u4ef6\u3002\u53ea\u9700\u4ece\u4e2a\u4eba\u7535\u8111\u7684\u6d4f\u89c8\u5668\u8bbf\u95ee\u60a8\u8ba2\u9605\u7684\u6a31\u82b1VPS\u7684IP\u5730\u5740\uff08\u5c06IP\u5730\u5740\u8f93\u5165URL\u680f\uff09\uff0c\u5982\u679c\u80fd\u770b\u5230Nginx\u7684\u521d\u59cb\u9875\u9762\uff0c\u5219\u8868\u793a\u6210\u529f\u3002<\/p>\n<h2>\u5c06Nginx\u7684\u8def\u5f84\u6dfb\u52a0\u8fdb\u53bb\u3002<\/h2>\n<p>\u867d\u7136\u6210\u529f\u5b89\u88c5\u4e86\u8be5\u8f6f\u4ef6\uff0c\u4f46\u662f\u6bcf\u6b21\u542f\u52a8\u3001\u505c\u6b62\u6216\u91cd\u65b0\u52a0\u8f7d\u65f6\u90fd\u9700\u8981\u8f93\u5165 &#8220;sudo \/usr\/local\/nginx\/sbin\/nginx&#8221; \u8fd9\u6837\u7684\u547d\u4ee4\uff0c\u8fd9\u6837\u5f88\u9ebb\u70e6\u3002\u6240\u4ee5\u6700\u597d\u8bbe\u7f6e\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>vim ~\/.bash_profile\r\n<\/code><\/pre>\n<p>\u8bf7\u5c06\u4ee5\u4e0b\u5185\u5bb9\u8bb0\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">export <\/span><span class=\"nv\">PATH<\/span><span class=\"o\">=<\/span>\/usr\/local\/nginx\/sbin:<span class=\"nv\">$PATH<\/span>\r\n<\/code><\/pre>\n<p>\u5982\u679c\u80fd\u591f\u4e66\u5199\u7684\u8bdd\uff0c\u91cd\u65b0\u52a0\u8f7d bash_profile\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">source<\/span> ~\/.bash_profile\r\n<\/code><\/pre>\n<p>\u5e94\u8be5\u53ef\u4ee5\u505a\u5230\u8fd9\u4ef6\u4e8b\u3002<\/p>\n<p>\u5982\u679c\u5728\u6267\u884csudo\u547d\u4ee4\u65f6\u88ab\u544a\u77e5\u627e\u4e0d\u5230\u547d\u4ee4\u7684\u4eba\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u7f16\u8f91visudo\uff0cnginx\u547d\u4ee4\u73b0\u5728\u5df2\u7ecf\u53ef\u4ee5\u8fd0\u884c\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>nginx <span class=\"nt\">-v<\/span>\r\n<span class=\"nb\">sudo<\/span>: nginx: \u30b3\u30de\u30f3\u30c9\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>visudo\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"c\"># Defaults   env_keep += \"HOME\"<\/span>\r\nDefaults    secure_path <span class=\"o\">=<\/span> \/sbin:\/bin:\/usr\/sbin:\/usr\/bin\r\n\u2193\r\nDefaults   env_keep +<span class=\"o\">=<\/span> <span class=\"s2\">\"HOME\"<\/span>\r\n<span class=\"c\"># Defaults    secure_path = \/sbin:\/bin:\/usr\/sbin:\/usr\/bin<\/span>\r\n<\/code><\/pre>\n<p>\u6211\u53ef\u4ee5\u5c3d\u60c5\u5730\u4f7f\u7528sudo\u547d\u4ee4\u6765\u64cd\u4f5cnginx\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>nginx <span class=\"nt\">-v<\/span>\r\nnginx version: nginx\/1.9.12\r\n<\/code><\/pre>\n<h2>\u8bbe\u7f6eNginx\u81ea\u52a8\u542f\u52a8<\/h2>\n<p>\u5b89\u88c5\u6e90\u7801\u7f16\u8bd1\u7684Nginx\u540e\uff0c\u7531\u4e8e\u65e0\u6cd5\u4f7f\u7528service\u6216chkconfig\u547d\u4ee4\uff0c\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\u4f7f\u5176\u53ef\u7528\u3002<\/p>\n<p>\u5728\/etc\/init.d\u4e2d\u521b\u5efa\u542f\u52a8\u811a\u672c\u5e76\u5c06\u5176\u53d8\u4e3a\u5b88\u62a4\u8fdb\u7a0b\uff0c\u4f7f\u5176\u80fd\u591f\u81ea\u52a8\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>vim \/etc\/init.d\/nginx\r\n<\/code><\/pre>\n<p>\u8bf7\u8bb0\u8ff0\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\">#!\/bin\/bash<\/span>\r\n\r\n<span class=\"c\">#chkconfig: 2345 80 30<\/span>\r\n<span class=\"c\">#description: nginx<\/span>\r\n<span class=\"nb\">set<\/span> <span class=\"nt\">-e<\/span>\r\n<span class=\"nv\">PATH<\/span><span class=\"o\">=<\/span>\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin\/:\/usr\/sbin:\/usr\/bin\r\n<span class=\"nv\">DESC<\/span><span class=\"o\">=<\/span><span class=\"s2\">\"nginx deamon\"<\/span>\r\n<span class=\"nv\">NAME<\/span><span class=\"o\">=<\/span>nginx\r\n<span class=\"nv\">DAEMON<\/span><span class=\"o\">=<\/span>\/usr\/local\/nginx\/sbin\/<span class=\"nv\">$NAME<\/span>\r\n<span class=\"nv\">SCRIPTNAME<\/span><span class=\"o\">=<\/span>\/etc\/init.d\/<span class=\"nv\">$NAME<\/span>\r\n\r\n<span class=\"nb\">test<\/span> <span class=\"nt\">-x<\/span> <span class=\"nv\">$DAEMON<\/span> <span class=\"o\">||<\/span> <span class=\"nb\">exit <\/span>0\r\n\r\nd_start<span class=\"o\">()<\/span> <span class=\"o\">{<\/span>\r\n        <span class=\"nv\">$DAEMON<\/span> <span class=\"o\">||<\/span> <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\" already running\"<\/span>\r\n<span class=\"o\">}<\/span>\r\n\r\nd_stop<span class=\"o\">()<\/span> <span class=\"o\">{<\/span>\r\n        <span class=\"nv\">$DAEMON<\/span> <span class=\"nt\">-s<\/span> stop <span class=\"o\">||<\/span> <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\" not running\"<\/span>\r\n<span class=\"o\">}<\/span>\r\n\r\nd_reload<span class=\"o\">()<\/span> <span class=\"o\">{<\/span>\r\n        <span class=\"nv\">$DAEMON<\/span> <span class=\"nt\">-s<\/span> reload <span class=\"o\">||<\/span> <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\" could not reload\"<\/span>\r\n<span class=\"o\">}<\/span>\r\n\r\n<span class=\"k\">case<\/span> <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\">\"<\/span> <span class=\"k\">in\r\n        <\/span>start<span class=\"p\">)<\/span>\r\n                <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\"Starting <\/span><span class=\"nv\">$DESC<\/span><span class=\"s2\">: <\/span><span class=\"nv\">$NAME<\/span><span class=\"s2\">\"<\/span>\r\n                d_start\r\n                <span class=\"nb\">echo<\/span> <span class=\"s2\">\".\"<\/span>\r\n        <span class=\"p\">;;<\/span>\r\n        stop<span class=\"p\">)<\/span>\r\n                <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\"Stopping <\/span><span class=\"nv\">$DESC<\/span><span class=\"s2\">: <\/span><span class=\"nv\">$NAME<\/span><span class=\"s2\">\"<\/span>\r\n                d_stop\r\n                <span class=\"nb\">echo<\/span> <span class=\"s2\">\".\"<\/span>\r\n        <span class=\"p\">;;<\/span>\r\n        reload<span class=\"p\">)<\/span>\r\n                <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\"Reloading <\/span><span class=\"nv\">$DESC<\/span><span class=\"s2\"> configuration...\"<\/span>\r\n                d_reload\r\n                <span class=\"nb\">echo<\/span> <span class=\"s2\">\"reloaded.\"<\/span>\r\n        <span class=\"p\">;;<\/span>\r\n        restart<span class=\"p\">)<\/span>\r\n                <span class=\"nb\">echo<\/span> <span class=\"nt\">-n<\/span> <span class=\"s2\">\"Restarting <\/span><span class=\"nv\">$DESC<\/span><span class=\"s2\">: <\/span><span class=\"nv\">$NAME<\/span><span class=\"s2\">\"<\/span>\r\n                d_stop\r\n                <span class=\"nb\">sleep <\/span>2\r\n                d_start\r\n                <span class=\"nb\">echo<\/span> <span class=\"s2\">\".\"<\/span>\r\n        <span class=\"p\">;;<\/span>\r\n        <span class=\"k\">*<\/span><span class=\"p\">)<\/span>\r\n                <span class=\"nb\">echo<\/span> <span class=\"s2\">\"Usage: <\/span><span class=\"nv\">$SCRIPTNAME<\/span><span class=\"s2\"> {start|stop|restart|reload}\"<\/span> <span class=\"o\">&gt;<\/span>&amp;2\r\n                <span class=\"nb\">exit <\/span>3\r\n        <span class=\"p\">;;<\/span>\r\n<span class=\"k\">esac<\/span>\r\n\r\n<span class=\"nb\">exit <\/span>0\r\n<\/code><\/pre>\n<p>\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u8bf7\u66f4\u6539\u6743\u9650\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo chmod<\/span> +x \/etc\/init.d\/nginx\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">ls<\/span> <span class=\"nt\">-l<\/span> \/etc\/init.d\/nginx\r\n<span class=\"nt\">-rwxr-xr-x<\/span> 1 root root 872  3\u6708  3 18:55 2016 \/etc\/init.d\/nginx\r\n<\/code><\/pre>\n<p>\u597d\u7684\u3002<br \/>\n\u5c06 nginx \u6dfb\u52a0\u5230 chkconfig\u3002<br \/>\n\u5c06 nginx \u52a0\u5165\u5230 chkconfig\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">sudo <\/span>chkconfig <span class=\"nt\">--add<\/span> nginx\r\n<span class=\"nv\">$ <\/span>chkconfig <span class=\"nt\">--list<\/span> nginx\r\nnginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off\r\n<\/code><\/pre>\n<p>\u73b0\u5728\u5df2\u7ecf\u8bbe\u5b9a\u4e3a\u81ea\u52a8\u542f\u52a8\u4e86\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u968f\u610f\u4fee\u6539 \/usr\/local\/nginx\/conf\/nginx.conf \u6587\u4ef6\u3002<\/p>\n<p>\u5c06Nginx\u5347\u7ea7\u5230\u652f\u6301HTTP\/2\u7684\u7248\u672c\u7684\u6545\u4e8b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6a31\u82b1\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668 \uff08\u8ffd\u8a18\uff1a2016-07-09\uff09 \u5982\u679c\u6309\u7167\u6b64\u5904\u7684\u65b9\u6cd5\u5b89\u88c5Nginx\uff0c \u53d1\u73b0openssl1. [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33209","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6700\u65b0\u7248\u672c\u7684nginx-1-9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1vps\u4e0a\u7684\u6545\u4e8b\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b\" \/>\n<meta property=\"og:description\" content=\"\u6a31\u82b1\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668 \uff08\u8ffd\u8a18\uff1a2016-07-09\uff09 \u5982\u679c\u6309\u7167\u6b64\u5904\u7684\u65b9\u6cd5\u5b89\u88c5Nginx\uff0c \u53d1\u73b0openssl1. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6700\u65b0\u7248\u672c\u7684nginx-1-9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1vps\u4e0a\u7684\u6545\u4e8b\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-19T01:50:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T18:33:37+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u9896\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u9896\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/\",\"name\":\"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-02-19T01:50:05+00:00\",\"dateModified\":\"2024-04-28T18:33:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\",\"name\":\"\u79d1, \u9896\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u9896\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u6700\u65b0\u7248\u672c\u7684nginx-1-9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1vps\u4e0a\u7684\u6545\u4e8b\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b","og_description":"\u6a31\u82b1\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668 \uff08\u8ffd\u8a18\uff1a2016-07-09\uff09 \u5982\u679c\u6309\u7167\u6b64\u5904\u7684\u65b9\u6cd5\u5b89\u88c5Nginx\uff0c \u53d1\u73b0openssl1. [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u6700\u65b0\u7248\u672c\u7684nginx-1-9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1vps\u4e0a\u7684\u6545\u4e8b\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-02-19T01:50:05+00:00","article_modified_time":"2024-04-28T18:33:37+00:00","author":"\u79d1, \u9896","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u9896","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/","name":"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-02-19T01:50:05+00:00","dateModified":"2024-04-28T18:33:37+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u6700\u65b0\u7248\u672c\u7684Nginx 1.9\u7cfb\u88ab\u5b89\u88c5\u5728\u6a31\u82b1VPS\u4e0a\u7684\u6545\u4e8b"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e","name":"\u79d1, \u9896","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","caption":"\u79d1, \u9896"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84nginx-1-9%e7%b3%bb%e8%a2%ab%e5%ae%89%e8%a3%85%e5%9c%a8%e6%a8%b1%e8%8a%b1vps%e4%b8%8a%e7%9a%84%e6%95%85%e4%ba%8b%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=33209"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33209\/revisions"}],"predecessor-version":[{"id":75339,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33209\/revisions\/75339"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=33209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=33209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=33209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}