{"id":1705,"date":"2017-09-24T18:21:05","date_gmt":"2017-09-24T10:21:05","guid":{"rendered":"https:\/\/zoco.me\/?p=25"},"modified":"2017-09-24T18:21:05","modified_gmt":"2017-09-24T10:21:05","slug":"centos-7-compile-nginx-and-build-into-rpm-package","status":"publish","type":"post","link":"https:\/\/cloudbool.com\/archive\/centos-7-compile-nginx-and-build-into-rpm-package.html","title":{"rendered":"CentOS 7 \u4e0b\u7f16\u8bd1Nginx\u5e76\u6253\u5305\u6210rpm"},"content":{"rendered":"<p>\u4e0a\u6b21\u8bf4\u7684\uff0c\u6700\u8fd1\u559c\u6b22\u4e0a\u4e86\u6298\u817eNginx\u3002\u4f5c\u4e3a\u4e00\u4e2aWeb\u4ece\u4e1a\u4eba\u5458\uff0c\u8d8a\u6765\u8d8a\u89c9\u5f97Nginx\u592a\u5f3a\u5927\u4e86\u3002<\/p>\n<p>\u4e8e\u662f\u4fbf\u82b1\u4e86\u51e0\u5929\u65f6\u95f4\u7814\u7a76\u5728Debian\u53caCentOS\u4e0b\u4ece\u6e90\u4ee3\u7801\u5f00\u59cb\u5c06Nginx\u6253\u5305\u6210deb\/rpm\uff0c\u8fd9\u7bc7\u662f\u8bb0\u5f55CentOS 7 \u4e0b\u5c06Nginx\u6253\u5305\u6210rpm\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u5b89\u88c5\u8f6f\u4ef6\u4e4b\u524d\u80af\u5b9a\u662f\u5148\u8981\u66f4\u65b0\uff1a<\/p>\n<blockquote><p>\n  yum update\n<\/p><\/blockquote>\n<p>\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\uff1a<\/p>\n<blockquote><p>\n  yum install gcc gcc-c++ rpm-build\n<\/p><\/blockquote>\n<p>\u5b89\u88c5Nginx\u6240\u4f9d\u8d56\u7684\u5305\uff1a<\/p>\n<blockquote><p>\n  yum install -y openssl-devel zlib-devel pcre-devel gd-devel\n<\/p><\/blockquote>\n<p>\u65b0\u5efa\u7528\u6237\uff1a<\/p>\n<p>name=rpmbuild<\/p>\n<p>useradd $name<\/p>\n<p>echo &#8220;$name ALL=(ALL) NOPASSWD:ALL&#8221; &gt;&gt; \/etc\/sudoers<\/p>\n<p>su &#8211; $name<\/p>\n<p>\u8fdb\u5165SOURCES\u76ee\u5f55\uff1a<\/p>\n<p>cd ~\/SOURCES\/<\/p>\n<p>\u5728\u65b0\u5efa\u7684\u7528\u6237home\u76ee\u5f55\u521b\u5efa\u63a5\u4e0b\u6765\u8981\u7528\u5230\u7684\u51e0\u4e2a\u6587\u4ef6\u5939\uff1a<\/p>\n<p>rpmdev-setuptree<\/p>\n<p>\u8fd9\u6837\u5728rpmbuild\u7684home\u76ee\u5f55\u4e0b\u9762\u6709\u4e86\u8fd9\u51e0\u4e2a\u76ee\u5f55\uff1a<\/p>\n<p>BUILD BUILDROOT RPMS SOURCES SPECS SRPMS<\/p>\n<p>\u5230\u8fd9\u4e2a\u5730\u5740\u627e\u5230\u5408\u9002\u7684\u6e90\u7801\u5305\u4e0b\u8f7d\uff1a nginx package<\/p>\n<p>\u4e0b\u8f7d\u6e90\u7801\uff0c\u5f53\u524d\uff082016-06-16\uff09\u6700\u65b0\u4e3anginx-1.10.1-1.el7.ngx.src.rpm\uff1a<\/p>\n<p>wget http:\/\/nginx.org\/packages\/centos\/7\/SRPMS\/nginx-1.10.1-1.el7.ngx.src.rpm<\/p>\n<p>\u89e3\u538b\uff1a<\/p>\n<p>rpm2cpio nginx-1.10.1-1.el7.ngx.src.rpm |cpio -dvi<\/p>\n<p>\u91cc\u9762\u5e94\u8be5\u6709\u8fd9\u4e48\u4e9b\u4e2a\u6587\u4ef6\uff1a<\/p>\n<p>[root@790fde35905f SOURCES]# ls<br \/>\nCOPYRIGHT                       nginx-debug.sysconf   nginx.sysconf<br \/>\nlogrotate                       nginx.conf            nginx.upgrade.sh<br \/>\nnginx-1.10.1                    nginx.init.in         nginx.vh.default.conf<br \/>\nnginx-1.10.1-1.el7.ngx.src.rpm  nginx.service         njs-1c50334fbea6.tar.gz<br \/>\nnginx-1.10.1.tar.gz             nginx.spec<br \/>\nnginx-debug.service             nginx.suse.logrotate<br \/>\n\u5f00\u59cb\u7f16\u8bd1\uff1a<\/p>\n<p>rpmbuild -ba nginx.spec<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u610f\u5916\u7684\u8bdd\uff0c\u5728~\/rpmbuild\/RPMS\/x86_64\u4e0b\u9762\u5e94\u8be5\u751f\u6210\u4e86\u5bf9\u5e94\u7684rpm\u5305\uff1a<\/p>\n<p>nginx-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-debuginfo-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-module-geoip-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-module-image-filter-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-module-njs-1.10.1.0.0.20160414.1c50334fbea6-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-module-perl-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\nnginx-module-xslt-1.10.1-1.el7.centos.ngx.x86_64.rpm<br \/>\n\u4e0a\u9762\u662f\u6309\u7167Nginx\u9ed8\u8ba4\u7684configure\u914d\u7f6e\u6253\u5305\u6210\u7684rpm\uff0c\u65e2\u7136\u9009\u62e9\u4e86\u81ea\u4e3b\u6253\u5305\u800c\u4e0d\u662f\u4f7f\u7528Nginx\u5b98\u65b9\u6253\u5305\u597d\u7684rpm\uff0c\u80af\u5b9a\u662f\u6709\u4e9b\u6a21\u5757Nginx\u6253\u5305\u7684\u4e0d\u5305\u542b\uff0c\u81ea\u4e3b\u6253\u5305\u4e5f\u5c31\u662f\u60f3\u628a\u6211\u4eec\u9700\u8981\u7684\u6a21\u5757\u52a0\u8fdbNginx\u800c\u53c8\u4e0d\u60f3\u5728\u751f\u4ea7\u670d\u52a1\u5668\u5b89\u88c5\u4e00\u5927\u5806\u5305\uff0c\u6240\u4ee5\uff0c\u4e3a\u4e86\u52a0\u8fdb\u6211\u4eec\u6240\u9700\u8981\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u6539\u4e0a\u9762\u54ea\u4e2anginx.spec\u6587\u4ef6\uff0c\u52a0\u8fdb\u6211\u4eec\u6240\u9700\u8981\u7684\u6a21\u5757\uff0c\u600e\u4e48\u52a0\u8fdb\u53bb\u53ef\u4ee5\u53c2\u8003\u6211\u5148\u524d\u7684\u4e00\u7bc7\u6587\u7ae0Debian 8 \u4e0b\u7f16\u8bd1Nginx\u7b14\u8bb0\u3002<\/p>\n<p>\u8fdb\u8fc7\u6211\u5b9e\u9645\u7f16\u8bd1\uff0c\u6682\u65f6\u53d1\u73b0\u6211\u6240\u9700\u8981\u7684\u4e24\u4e2a\u989d\u5916\u6a21\u5757Google Filter\u548cPageSpeed\u4e2dGoogle Filter\u53ef\u4ee5\u6b63\u5e38\u7f16\u8bd1\u8fdb\u53bb\uff0c\u4f46\u662fPageSpeed\u4f1a\u62a5\u9519\uff0c\u6682\u65f6\u6ca1\u627e\u5230\u89e3\u51b3\u529e\u6cd5\uff0c\u6709\u65f6\u95f4\u6211\u518d\u6298\u817e\u4e00\u4e0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u6b21\u8bf4\u7684\uff0c\u6700\u8fd1\u559c\u6b22\u4e0a\u4e86\u6298\u817eNginx\u3002\u4f5c\u4e3a\u4e00\u4e2aWeb\u4ece\u4e1a\u4eba\u5458\uff0c\u8d8a\u6765\u8d8a\u89c9\u5f97Nginx\u592a\u5f3a\u5927\u4e86\u3002 \u4e8e\u662f\u4fbf\u82b1\u4e86\u51e0\u5929\u65f6 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/cloudbool.com\/archive\/centos-7-compile-nginx-and-build-into-rpm-package.html\"> <span class=\"screen-reader-text\">CentOS 7 \u4e0b\u7f16\u8bd1Nginx\u5e76\u6253\u5305\u6210rpm<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[17,76],"class_list":["post-1705","post","type-post","status-publish","format-standard","hentry","category-tech","tag-centos","tag-nginx"],"_links":{"self":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/comments?post=1705"}],"version-history":[{"count":0,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1705\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/media?parent=1705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/categories?post=1705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/tags?post=1705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}