{"id":3077,"date":"2016-12-17T22:59:32","date_gmt":"2016-12-17T14:59:32","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=3077"},"modified":"2016-12-17T22:59:32","modified_gmt":"2016-12-17T14:59:32","slug":"%e5%a6%82%e4%bd%95%e6%9b%b4%e5%a5%bd%e7%9a%84%e6%89%8b%e5%b7%a5%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/3077.html","title":{"rendered":"\u5982\u4f55\u66f4\u597d\u7684\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5Nginx"},"content":{"rendered":"<p>=Start=<\/p>\n<h4>\u7f18\u7531\uff1a<\/h4>\n<p>\u4e3a\u4e86\u80fd\u5728Nginx\u4e0a\u4f7f\u7528\u4e00\u4e9b\u989d\u5916\u7684\u529f\u80fd\/\u6a21\u5757\uff0c\u4e00\u822c\u90fd\u662f\u9700\u8981\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5Nginx\u7684\uff0c\u8fd9\u5bf9\u4e8e\u4e13\u95e8\u7814\u7a76Nginx\u6216\u5bf9\u6b64\u6bd4\u8f83\u719f\u6089\u7684\u4eba\u6765\u8bf4\u4e0d\u7b97\u9ebb\u70e6\uff0c\u4f46\u5bf9\u4e8e\u6211\u8fd9\u79cd\u65b0\u624b\u6765\u8bf4\u5c31\u975e\u5e38\u9ebb\u70e6\u4e86\u2014\u2014\u5982\u679c\u53ea\u662f\u7b80\u5355\u7684\u8bbe\u7f6e\u300c<code>--prefix<\/code>\u300d\u3001\u300c<code>--with-pcre<\/code>\u300d\u7b49\u51e0\u4e2a\u7f16\u8bd1\u9009\u9879\u7684\u8bdd\uff0c\u6211\u4e5f\u4f1a\u4e00\u70b9\uff0c\u4f46\u5982\u679c\u8003\u8651\u5f97\u4e0d\u5168\u9762\u7684\u8bdd\u540e\u671f\u8fd8\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff0c\u4f46\u8be5\u6dfb\u52a0\u54ea\u4e9b\u9009\u9879\u6211\u8fd8\u771f\u4e0d\u6e05\u695a\uff1b\u8fd8\u6709\u5c31\u662f\u5982\u679c\u5b8c\u5168\u91cd\u5934\u5f00\u59cb\u7f16\u8bd1Nginx\u7684\u8bdd\uff0c\u7528\u6237\u3001\u7ec4\u7684\u521b\u5efa\uff0c\u542f\u52a8\u811a\u672c\u7684\u7f16\u5199\u7b49\u90fd\u662f\u9700\u8981\u81ea\u5df1\u6765\u5904\u7406\u7684\uff0c\u8fd9\u4e5f\u662f\u6211\u4e3a\u4ec0\u4e48\u4e00\u76f4\u90fd\u6bd4\u8f83\u5fcc\u60ee\u4ece\u5934\u7f16\u8bd1Nginx\u7b49\u7cfb\u7edf\u8f6f\u4ef6\u7684\u539f\u56e0\uff0c\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u592a\u591a\u4e86\u3002<\/p>\n<p>\u4f46\u4eca\u5929\u5728\u6d4b\u8bd5\u4e00\u4e2aNginx\u6a21\u5757\u7684\u65f6\u5019\u5b66\u5230\u4e86\u4e00\u4e2a\u6bd4\u8f83\u597d\u7684\u529e\u6cd5\uff0c\u81ea\u5df1\u5b9e\u9645\u5728 CentOS 7 \u6d4b\u8bd5\u4e86\u4e00\u4e0b\uff0c\u633a\u597d\u7528\u7684\u3002\u4e8e\u662f\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b9\u4fbf\u4ee5\u540e\u53c2\u8003\u3002<\/p>\n<h4>\u6b63\u6587\uff1a<\/h4>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<p>\u5b8c\u5168\u4ece\u5934\u5f00\u59cb\u6307\u5b9aNginx\u7684\u7f16\u8bd1\u9009\u9879\u5bf9\u6211\u6765\u8bf4\u663e\u7136\u4e0d\u73b0\u5b9e\uff0c\u4e00\u4e2a\u66f4\u597d\u7684\u529e\u6cd5\u662f\u53c2\u7167\u7cfb\u7edf\u7684\u7f16\u8bd1\u9009\u9879\uff0c\u7136\u540e\u6839\u636e\u5b9e\u9645\u9700\u8981\u589e\u52a0\u51e0\u4e2a\u300c<code>--add-module<\/code>\u300d\u9009\u9879\u5373\u53ef\u5f88\u597d\u7684\u7ed3\u5408\u4e8c\u8005\u7684\u4f18\u70b9\uff08\u65b9\u4fbf\u5feb\u901f&amp;\u53ef\u5b9a\u5236\uff09\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># \u9996\u5148\u7528yum\u7684\u65b9\u5f0f\u5728CentOS 7\u4e0a\u5b89\u88c5Nginx\u53ca\u9700\u8981\u7684\u6a21\u5757\n# rpm -Uvh http:\/\/nginx.org\/packages\/centos\/7\/noarch\/RPMS\/nginx-release-centos-7-0.el7.ngx.noarch.rpm\n# yum install nginx nginx-module-xslt nginx-module-perl nginx-module-image-filter nginx-module-geoip\n\n# \u7136\u540e\u901a\u8fc7\u300c-V\u300d\u9009\u9879\u67e5\u770byum\u547d\u4ee4\u5728\u5b89\u88c5\u65f6\u7ed9\u5b83\u8bbe\u7f6e\u4e86\u54ea\u4e9b\u7f16\u8bd1\u9009\u9879\n# nginx -V<\/pre>\n<p>&amp;<\/p>\n<pre class=\"lang:default decode:true \"># \u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u76ee\u5f55\u7528\u4e8e\u5b58\u653e\u7f16\u8bd1Nginx\u9700\u8981\u7684\u8f6f\u4ef6\n$ mkdir compile_nginx\n$ cd compile_nginx\n\n$ git clone https:\/\/github.com\/cuber\/ngx_http_google_filter_module\n$ git clone https:\/\/github.com\/yaoweibin\/ngx_http_substitutions_filter_module\n\n$ wget https:\/\/github.com\/pagespeed\/ngx_pagespeed\/archive\/v1.12.34.2-beta.tar.gz\n$ mv v1.12.34.2-beta.tar.gz ngx_pagespeed.1.12.34.2-beta.tar.gz\n$ tar zxf ngx_pagespeed.1.12.34.2-beta.tar.gz\n\n# \u4e00\u822c\u5efa\u8bae\u662f\u4e0b\u8f7d\u548cyum\u547d\u4ee4\u5b89\u88c5\u7684Nginx\u76f8\u540c\u7248\u672c\u7684\u8fdb\u884c\u91cd\u65b0\u7f16\u8bd1\uff0c\u4e0d\u8fc7\u5982\u679c\u4f60\u60f3\u4f53\u9a8c\u65b0\u7248\u672c\u7684Nginx\uff0c\u4e5f\u53ef\u4ee5\u5148\u7f16\u8bd1\u8bd5\u8bd5\uff0c\u4e00\u822c\u4e5f\u6ca1\u4ec0\u4e48\u95ee\u9898\n$ wget http:\/\/nginx.org\/download\/nginx-1.11.7.tar.gz\n$ tar zxf nginx-1.11.7.tar.gz\n$ cd nginx-1.11.7\n# \u4f7f\u7528\u4e0a\u9762\u7684\u300cnginx -V\u300d\u547d\u4ee4\u7ed9\u51fa\u7684\u7f16\u8bd1\u9009\u9879\uff0c\u7136\u540e\u5728\u672b\u5c3e\u6dfb\u52a0\u4e0a\u81ea\u5df1\u9700\u8981\u7684\u9009\u9879\n$ .\/configure \\\n --prefix=\/etc\/nginx \\\n --sbin-path=\/usr\/sbin\/nginx \\\n --modules-path=\/usr\/lib64\/nginx\/modules \\\n --conf-path=\/etc\/nginx\/nginx.conf \\\n --error-log-path=\/var\/log\/nginx\/error.log \\\n --http-log-path=\/var\/log\/nginx\/access.log \\\n --pid-path=\/var\/run\/nginx.pid \\\n --lock-path=\/var\/run\/nginx.lock \\\n --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp \\\n --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp \\\n --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp \\\n --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp \\\n --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp \\\n --user=nginx \\\n --group=nginx \\\n --with-file-aio \\\n --with-threads \\\n --with-http_addition_module \\\n --with-http_auth_request_module \\\n --with-http_dav_module \\\n --with-http_flv_module \\\n --with-http_gunzip_module \\\n --with-http_gzip_static_module \\\n --with-http_mp4_module \\\n --with-http_random_index_module \\\n --with-http_realip_module \\\n --with-http_secure_link_module \\\n --with-http_slice_module \\\n --with-http_ssl_module \\\n --with-http_stub_status_module \\\n --with-http_sub_module \\\n --with-http_v2_module \\\n --with-mail \\\n --with-mail_ssl_module \\\n --with-stream \\\n --with-stream_ssl_module \\\n --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \\\n --add-module=..\/ngx_http_google_filter_module \\\n --add-module=..\/ngx_http_substitutions_filter_module \\\n --add-module=..\/ngx_pagespeed-1.12.34.2-beta\n$ make\n\n$ sudo cp \/usr\/sbin\/nginx{,.orig}\n$ sudo cp -rf objs\/nginx \/usr\/sbin\/nginx<\/pre>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"https:\/\/github.com\/cuber\/ngx_http_google_filter_module\/blob\/master\/README.zh-CN.md#\u4ece\u53d1\u884c\u7248\u8fc1\u79fb\">https:\/\/github.com\/cuber\/ngx_http_google_filter_module\/blob\/master\/README.zh-CN.md#\u4ece\u53d1\u884c\u7248\u8fc1\u79fb<\/a><\/li>\n<li><a href=\"https:\/\/developers.google.com\/speed\/pagespeed\/module\/build_ngx_pagespeed_from_source\">https:\/\/developers.google.com\/speed\/pagespeed\/module\/build_ngx_pagespeed_from_source<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e3a\u4e86\u80fd\u5728Nginx\u4e0a\u4f7f\u7528\u4e00\u4e9b\u989d\u5916\u7684\u529f\u80fd\/\u6a21\u5757\uff0c\u4e00\u822c\u90fd\u662f\u9700\u8981\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5Nginx\u7684\uff0c\u8fd9 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[703,75],"class_list":["post-3077","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-compile","tag-nginx"],"views":8900,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=3077"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3077\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=3077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=3077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=3077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}