{"id":17,"date":"2018-04-10T23:19:39","date_gmt":"2018-04-10T15:19:39","guid":{"rendered":"http:\/\/esufy.com\/?p=17"},"modified":"2024-03-10T15:37:29","modified_gmt":"2024-03-10T07:37:29","slug":"linux%e4%b8%8b%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"http:\/\/www.esufy.cn\/?p=17","title":{"rendered":"Linux\u4e0b\u5b89\u88c5Nginx"},"content":{"rendered":"<p><strong>\u5b89\u88c5\u6240\u9700\u73af\u5883<\/strong><br \/>\nNginx \u662f C\u8bed\u8a00 \u5f00\u53d1\uff0c\u5efa\u8bae\u5728 Linux \u4e0a\u8fd0\u884c\uff0c\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u5b89\u88c5 Windows \u7248\u672c\uff0c\u672c\u7bc7\u5219\u4f7f\u7528 CentOS 7 \u4f5c\u4e3a\u5b89\u88c5\u73af\u5883\u3002<br \/>\n\u4e00. gcc \u5b89\u88c5<br \/>\n\u5b89\u88c5 nginx \u9700\u8981\u5148\u5c06\u5b98\u7f51\u4e0b\u8f7d\u7684\u6e90\u7801\u8fdb\u884c\u7f16\u8bd1\uff0c\u7f16\u8bd1\u4f9d\u8d56 gcc \u73af\u5883\uff0c\u5982\u679c\u6ca1\u6709 gcc \u73af\u5883\uff0c\u5219\u9700\u8981\u5b89\u88c5\uff1a<br \/>\nyum install gcc-c++<br \/>\n\u4e8c. PCRE pcre-devel \u5b89\u88c5<br \/>\nPCRE(Perl Compatible Regular Expressions) \u662f\u4e00\u4e2aPerl\u5e93\uff0c\u5305\u62ec perl \u517c\u5bb9\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5e93\u3002nginx \u7684 http \u6a21\u5757\u4f7f\u7528 pcre \u6765\u89e3\u6790\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u6240\u4ee5\u9700\u8981\u5728 linux \u4e0a\u5b89\u88c5 pcre \u5e93\uff0cpcre-devel \u662f\u4f7f\u7528 pcre \u5f00\u53d1\u7684\u4e00\u4e2a\u4e8c\u6b21\u5f00\u53d1\u5e93\u3002nginx\u4e5f\u9700\u8981\u6b64\u5e93\u3002\u547d\u4ee4\uff1a<br \/>\nyum install -y pcre pcre-devel<br \/>\n\u4e09. zlib \u5b89\u88c5<br \/>\nzlib \u5e93\u63d0\u4f9b\u4e86\u5f88\u591a\u79cd\u538b\u7f29\u548c\u89e3\u538b\u7f29\u7684\u65b9\u5f0f\uff0c nginx \u4f7f\u7528 zlib \u5bf9 http \u5305\u7684\u5185\u5bb9\u8fdb\u884c gzip \uff0c\u6240\u4ee5\u9700\u8981\u5728 Centos \u4e0a\u5b89\u88c5 zlib \u5e93\u3002<br \/>\nyum install -y zlib zlib-devel<br \/>\n\u56db. OpenSSL \u5b89\u88c5<br \/>\nOpenSSL \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5b89\u5168\u5957\u63a5\u5b57\u5c42\u5bc6\u7801\u5e93\uff0c\u56ca\u62ec\u4e3b\u8981\u7684\u5bc6\u7801\u7b97\u6cd5\u3001\u5e38\u7528\u7684\u5bc6\u94a5\u548c\u8bc1\u4e66\u5c01\u88c5\u7ba1\u7406\u529f\u80fd\u53ca SSL \u534f\u8bae\uff0c\u5e76\u63d0\u4f9b\u4e30\u5bcc\u7684\u5e94\u7528\u7a0b\u5e8f\u4f9b\u6d4b\u8bd5\u6216\u5176\u5b83\u76ee\u7684\u4f7f\u7528\u3002<br \/>\nnginx \u4e0d\u4ec5\u652f\u6301 http \u534f\u8bae\uff0c\u8fd8\u652f\u6301 https\uff08\u5373\u5728ssl\u534f\u8bae\u4e0a\u4f20\u8f93http\uff09\uff0c\u6240\u4ee5\u9700\u8981\u5728 Centos \u5b89\u88c5 OpenSSL \u5e93\u3002<br \/>\nyum install -y openssl openssl-devel<br \/>\n<strong>\u5b98\u7f51\u4e0b\u8f7d<\/strong><br \/>\n1.\u76f4\u63a5\u4e0b\u8f7d.tar.gz\u5b89\u88c5\u5305\uff0c\u5730\u5740\uff1ahttps:\/\/nginx.org\/en\/download.html<br \/>\n2.\u4f7f\u7528wget\u547d\u4ee4\u4e0b\u8f7d\uff08\u63a8\u8350\uff09\u3002<br \/>\nwget -c https:\/\/nginx.org\/download\/nginx-1.10.1.tar.gz<br \/>\n\u6211\u4e0b\u8f7d\u7684\u662f1.10.1\u7248\u672c\uff0c\u8fd9\u4e2a\u662f\u76ee\u524d\u7684\u7a33\u5b9a\u7248\u3002<br \/>\n<strong>\u89e3\u538b<\/strong><br \/>\n\u4f9d\u7136\u662f\u76f4\u63a5\u547d\u4ee4\uff1a<br \/>\ntar -zxvf nginx-1.10.1.tar.gzcd nginx-1.10.1<br \/>\n<strong>\u914d\u7f6e<\/strong><br \/>\n\u5176\u5b9e\u5728 nginx-1.10.1 \u7248\u672c\u4e2d\u4f60\u5c31\u4e0d\u9700\u8981\u53bb\u914d\u7f6e\u76f8\u5173\u4e1c\u897f\uff0c\u9ed8\u8ba4\u5c31\u53ef\u4ee5\u4e86\u3002\u5f53\u7136\uff0c\u5982\u679c\u4f60\u8981\u81ea\u5df1\u914d\u7f6e\u76ee\u5f55\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<br \/>\n1.\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e<br \/>\n.\/configure<br \/>\n2.\u81ea\u5b9a\u4e49\u914d\u7f6e\uff08\u4e0d\u63a8\u8350\uff09<br \/>\n.\/configure \\<br \/>\n&#8211;prefix=\/usr\/local\/nginx \\<br \/>\n&#8211;conf-path=\/usr\/local\/nginx\/conf\/nginx.conf \\<br \/>\n&#8211;pid-path=\/usr\/local\/nginx\/conf\/nginx.pid \\<br \/>\n&#8211;lock-path=\/var\/lock\/nginx.lock \\<br \/>\n&#8211;error-log-path=\/var\/log\/nginx\/error.log \\<br \/>\n&#8211;http-log-path=\/var\/log\/nginx\/access.log \\<br \/>\n&#8211;with-http_gzip_static_module \\<br \/>\n&#8211;http-client-body-temp-path=\/var\/temp\/nginx\/client \\<br \/>\n&#8211;http-proxy-temp-path=\/var\/temp\/nginx\/proxy \\<br \/>\n&#8211;http-fastcgi-temp-path=\/var\/temp\/nginx\/fastcgi \\<br \/>\n&#8211;http-uwsgi-temp-path=\/var\/temp\/nginx\/uwsgi \\<br \/>\n&#8211;http-scgi-temp-path=\/var\/temp\/nginx\/scgi<br \/>\n\u6ce8\uff1a\u5c06\u4e34\u65f6\u6587\u4ef6\u76ee\u5f55\u6307\u5b9a\u4e3a\/var\/temp\/nginx\uff0c\u9700\u8981\u5728\/var\u4e0b\u521b\u5efatemp\u53canginx\u76ee\u5f55\u7f16\u8bd1\u5b89\u88c5<br \/>\nmake<br \/>\nmake install<br \/>\n\u67e5\u627e\u5b89\u88c5\u8def\u5f84\uff1a<br \/>\nwhereis nginx<br \/>\n<strong>\u542f\u52a8\u3001\u505c\u6b62nginx<\/strong><br \/>\ncd \/usr\/local\/nginx\/sbin\/<br \/>\n.\/nginx<br \/>\n.\/nginx -s stop<br \/>\n.\/nginx -s quit<br \/>\n.\/nginx -s reload<br \/>\n.\/nginx -s quit:\u6b64\u65b9\u5f0f\u505c\u6b62\u6b65\u9aa4\u662f\u5f85nginx\u8fdb\u7a0b\u5904\u7406\u4efb\u52a1\u5b8c\u6bd5\u8fdb\u884c\u505c\u6b62\u3002<br \/>\n.\/nginx -s stop:\u6b64\u65b9\u5f0f\u76f8\u5f53\u4e8e\u5148\u67e5\u51fanginx\u8fdb\u7a0bid\u518d\u4f7f\u7528kill\u547d\u4ee4\u5f3a\u5236\u6740\u6389\u8fdb\u7a0b\u3002<br \/>\n\u67e5\u8be2nginx\u8fdb\u7a0b\uff1a<br \/>\nps aux|grep nginx<br \/>\n<strong>\u91cd\u542f nginx<\/strong><br \/>\n1.\u5148\u505c\u6b62\u518d\u542f\u52a8\uff08\u63a8\u8350\uff09\uff1a<br \/>\n\u5bf9 nginx \u8fdb\u884c\u91cd\u542f\u76f8\u5f53\u4e8e\u5148\u505c\u6b62\u518d\u542f\u52a8\uff0c\u5373\u5148\u6267\u884c\u505c\u6b62\u547d\u4ee4\u518d\u6267\u884c\u542f\u52a8\u547d\u4ee4\u3002\u5982\u4e0b\uff1a<br \/>\n.\/nginx -s quit<br \/>\n.\/nginx<br \/>\n2.\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\uff1a<br \/>\n\u5f53 ngin x\u7684\u914d\u7f6e\u6587\u4ef6 nginx.conf \u4fee\u6539\u540e\uff0c\u8981\u60f3\u8ba9\u914d\u7f6e\u751f\u6548\u9700\u8981\u91cd\u542f nginx\uff0c\u4f7f\u7528-s reload\u4e0d\u7528\u5148\u505c\u6b62 ngin x\u518d\u542f\u52a8 nginx \u5373\u53ef\u5c06\u914d\u7f6e\u4fe1\u606f\u5728 nginx \u4e2d\u751f\u6548\uff0c\u5982\u4e0b\uff1a<br \/>\n.\/nginx -s reload<br \/>\n<strong>\u5f00\u673a\u81ea\u542f\u52a8<\/strong><br \/>\n\u5373\u5728rc.local\u589e\u52a0\u542f\u52a8\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\nvi \/etc\/rc.local<br \/>\n\u589e\u52a0\u4e00\u884c \/usr\/local\/nginx\/sbin\/nginx<br \/>\n\u8bbe\u7f6e\u6267\u884c\u6743\u9650\uff1achmod 755 rc.local<br \/>\n\u5230\u8fd9\u91cc\uff0cnginx\u5c31\u5b89\u88c5\u5b8c\u6bd5\u4e86\uff0c\u542f\u52a8\u3001\u505c\u6b62\u3001\u91cd\u542f\u64cd\u4f5c\u4e5f\u90fd\u5b8c\u6210\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u6240\u9700\u73af\u5883 Nginx \u662f C\u8bed\u8a00 \u5f00\u53d1\uff0c\u5efa\u8bae\u5728 Linux \u4e0a\u8fd0\u884c\uff0c\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u5b89\u88c5 Windows \u7248\u672c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[11],"_links":{"self":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/17"}],"collection":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":1,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":161,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/161"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/media\/299"}],"wp:attachment":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}