{"id":412,"date":"2024-03-29T10:44:07","date_gmt":"2024-03-29T02:44:07","guid":{"rendered":"https:\/\/xianyijitan.top\/?p=412"},"modified":"2025-10-21T22:05:41","modified_gmt":"2025-10-21T14:05:41","slug":"centos7%e5%ae%89%e8%a3%85-nginx","status":"publish","type":"post","link":"https:\/\/xianyijitan.top\/?p=412","title":{"rendered":"centos7\u5b89\u88c5 nginx"},"content":{"rendered":"<p>yum\u6e90\u5b89\u88c5\uff1awget -O \/etc\/yum.repos.d\/epel.repo <a href=\"http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo\">http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo<\/a><\/p>\n<h3><strong>\u4e00\u3001\u5b89\u88c5\u6240\u9700\u63d2\u4ef6<\/strong><\/h3>\n<h4><strong>1\u3001\u5b89\u88c5<\/strong> <strong>gcc<\/strong><\/h4>\n<blockquote>\n<p>gcc\u662flinux\u4e0b\u7684\u7f16\u8bd1\u5668\uff0c\u5b83\u53ef\u4ee5\u7f16\u8bd1 C,C++,Ada,Object C\u548cJava\u7b49\u8bed\u8a00\u3002<\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">yum -y install gcc<\/code><\/pre>\n<h4><strong>2\u3001\u5b89\u88c5pcre\u3001pcre-devel<\/strong><\/h4>\n<blockquote>\n<p>pcre\u662f\u4e00\u4e2aperl\u5e93\uff0c\u5305\u62ecperl\u517c\u5bb9\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5e93\uff0cnginx\u7684http\u6a21\u5757\u4f7f\u7528pcre\u6765\u89e3\u6790\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">yum install -y pcre pcre-devel<\/code><\/pre>\n<h4><strong>3\u3001zlib\u5b89\u88c5<\/strong><\/h4>\n<blockquote>\n<p>zlib\u5e93\u63d0\u4f9b\u4e86\u5f88\u591a\u79cd\u538b\u7f29\u548c\u89e3\u538b\u7f29\u65b9\u5f0fnginx\u4f7f\u7528zlib\u5bf9http\u5305\u7684\u5185\u5bb9\u8fdb\u884cgzip\uff0c\u6240\u4ee5\u9700\u8981\u5b89\u88c5\u3002  <\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">yum install -y zlib zlib-devel<\/code><\/pre>\n<h4><strong>4\u3001\u5b89\u88c5openssl<\/strong><\/h4>\n<blockquote>\n<p>openssl\u662fweb\u5b89\u5168\u901a\u4fe1\u7684\u57fa\u77f3\u3002  <\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">yum install -y openssl openssl-devel<\/code><\/pre>\n<h3><strong>\u4e8c\u3001\u5b89\u88c5nginx<\/strong><\/h3>\n<h4><strong>1\u3001\u4e0b\u8f7dnginx\u5b89\u88c5\u5305<\/strong><\/h4>\n<p><a href=\"https:\/\/nginx.org\/en\/download.html\">https:\/\/nginx.org\/en\/download.html<\/a><\/p>\n<pre><code class=\"language-JavaScript\">wget http:\/\/nginx.org\/download\/nginx-1.20.2.tar.gz<\/code><\/pre>\n<h4><strong>2\u3001\u628a\u538b\u7f29\u5305\u89e3\u538b\u5230\/usr\/local\/src\/<\/strong><\/h4>\n<pre><code class=\"language-JavaScript\">tar -zxvf nginx-1.20.2.tar.gz -C \/usr\/local\/src\/<\/code><\/pre>\n<h4><strong>3\u3001\u8fdb\u5165\u5b89\u88c5\u5305\u76ee\u5f55<\/strong><\/h4>\n<pre><code class=\"language-JavaScript\">cd \/usr\/local\/src\/nginx-1.20.2<\/code><\/pre>\n<h4><strong>4\u3001\u7f16\u8bd1\u5b89\u88c5<\/strong><\/h4>\n<blockquote>\n<p>\u6267\u884c\u4ee5\u4e0b\u4e09\u4e2a\u547d\u4ee4\uff1a  <\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">.\/configure\nmake\nmake install<\/code><\/pre>\n<h4><strong>5\u3001\u5207\u6362\u5230\/usr\/local\/nginx\u5b89\u88c5\u76ee\u5f55<\/strong><\/h4>\n<pre><code class=\"language-JavaScript\">cd \/usr\/local\/nginx<\/code><\/pre>\n<h4><strong>6\u3001\u542f\u52a8 nginx \u670d\u52a1<\/strong><\/h4>\n<pre><code class=\"language-JavaScript\">.\/sbin\/nginx<\/code><\/pre>\n<h4><strong>7\u3001\u67e5\u770bnginx\u670d\u52a1\u662f\u5426\u542f\u52a8\u6210\u529f<\/strong><\/h4>\n<pre><code class=\"language-JavaScript\">ps -ef | grep nginx<\/code><\/pre>\n<h4><strong>8\u3001\u9632\u706b\u5899\u653e\u884ctcp80<\/strong>\u7aef\u53e3<\/h4>\n<pre><code class=\"language-JavaScript\">firewall-cmd --add-port=80\/tcp\nfirewall-cmd --add-port=80\/tcp --permanent #\u5199\u5165\u914d\u7f6e\u6587\u4ef6\u6c38\u4e45\u653e\u884c<\/code><\/pre>\n<h4><strong>9\u3001\u8bbf\u95ee\u4f60\u7684\u670d\u52a1\u5668**<\/strong>IP**<\/h4>\n<blockquote>\n<p>\u663e\u793a\u6b64\u6b22\u8fce\u754c\u9762\u5c31\u8bf4\u660enginx \u5b89\u88c5\u6210\u529f\u4e86  <\/p>\n<\/blockquote>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/xianyijitan.top\/wp-blog\/typora-user-images\/centos7-1.png?w=960&#038;ssl=1\" alt=\"img\" \/><\/p>\n<p>centos7 \u5b89\u88c5 nginx<\/p>\n<h3><strong>\u4e09\u3001Nginx \u5176\u4ed6\u547d\u4ee4<\/strong><\/h3>\n<blockquote>\n<p>\u4ee5\u4e0b\u5305\u542b\u4e86 Nginx \u5e38\u7528\u7684\u51e0\u4e2a\u547d\u4ee4\uff1a<\/p>\n<\/blockquote>\n<pre><code class=\"language-JavaScript\">nginx -s reload            # \u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6\nnginx -s reopen            # \u91cd\u542f Nginx\nnginx -s stop              # \u505c\u6b62 Nginx<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>yum\u6e90\u5b89\u88c5\uff1awget -O \/etc\/yum.repos.d\/epel.repo http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo \u4e00\u3001\u5b89\u88c5\u6240\u9700\u63d2\u4ef6 1\u3001\u5b89\u88c5 gcc gcc\u662flinux\u4e0b\u7684\u7f16\u8bd1\u5668\uff0c\u5b83\u53ef\u4ee5\u7f16\u8bd1 C,C++,Ada,Object C\u548cJava\u7b49\u8bed\u8a00\u3002 yum -y install gcc 2\u3001\u5b89\u88c5pcre\u3001pcre-devel pcre\u662f\u4e00\u4e2aperl\u5e93\uff0c\u5305\u62ecperl\u517c\u5bb9\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5e93\uff0cnginx\u7684http\u6a21\u5757\u4f7f\u7528pcre\u6765\u89e3\u6790\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 yum install -y pcre pcre-devel 3\u3001zlib\u5b89\u88c5 zlib\u5e93\u63d0\u4f9b\u4e86\u5f88\u591a\u79cd\u538b\u7f29\u548c\u89e3\u538b\u7f29\u65b9\u5f0fnginx\u4f7f\u7528zlib\u5bf9http\u5305\u7684\u5185\u5bb9\u8fdb\u884cgzip\uff0c\u6240\u4ee5\u9700\u8981\u5b89\u88c5\u3002 yum install -y zlib zlib-devel 4\u3001\u5b89\u88c5openssl openssl\u662fweb\u5b89\u5168\u901a\u4fe1\u7684\u57fa\u77f3\u3002 yum install -y openssl openssl-devel \u4e8c\u3001\u5b89\u88c5nginx 1\u3001\u4e0b\u8f7dnginx\u5b89\u88c5\u5305 https:\/\/nginx.org\/en\/download.html wget http:\/\/nginx.org\/download\/nginx-1.20.2.tar.gz 2\u3001\u628a\u538b\u7f29\u5305\u89e3\u538b\u5230\/usr\/local\/src\/ tar -zxvf nginx-1.20.2.tar.gz -C \/usr\/local\/src\/ 3\u3001\u8fdb\u5165\u5b89\u88c5\u5305\u76ee\u5f55 cd \/usr\/local\/src\/nginx-1.20.2 4\u3001\u7f16\u8bd1\u5b89\u88c5 \u6267\u884c\u4ee5\u4e0b\u4e09\u4e2a\u547d\u4ee4\uff1a .\/configure make make install 5\u3001\u5207\u6362\u5230\/usr\/local\/nginx\u5b89\u88c5\u76ee\u5f55 cd \/usr\/local\/nginx 6\u3001\u542f\u52a8 nginx \u670d\u52a1 .\/sbin\/nginx 7\u3001\u67e5\u770bnginx\u670d\u52a1\u662f\u5426\u542f\u52a8\u6210\u529f ps -ef | grep nginx 8\u3001\u9632\u706b\u5899\u653e\u884ctcp80\u7aef\u53e3 firewall-cmd &#8211;add-port=80\/tcp firewall-cmd &#8211;add-port=80\/tcp &#8211;permanent #\u5199\u5165\u914d\u7f6e\u6587\u4ef6\u6c38\u4e45\u653e\u884c 9\u3001\u8bbf\u95ee\u4f60\u7684\u670d\u52a1\u5668**IP** \u663e\u793a\u6b64\u6b22\u8fce\u754c\u9762\u5c31\u8bf4\u660enginx \u5b89\u88c5\u6210\u529f\u4e86 centos7 \u5b89\u88c5 nginx \u4e09\u3001Nginx \u5176\u4ed6\u547d\u4ee4 \u4ee5\u4e0b\u5305\u542b\u4e86 Nginx \u5e38\u7528\u7684\u51e0\u4e2a\u547d\u4ee4\uff1a nginx -s reload # \u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6 nginx -s reopen # \u91cd\u542f Nginx nginx -s stop # \u505c\u6b62 Nginx<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-412","post","type-post","status-publish","format-standard","hentry","category-lixx"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=412"}],"version-history":[{"count":3,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":468,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions\/468"}],"wp:attachment":[{"href":"https:\/\/xianyijitan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xianyijitan.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}