{"id":42898,"date":"2024-10-04T08:26:40","date_gmt":"2024-10-04T00:26:40","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42898\/"},"modified":"2024-10-04T08:26:40","modified_gmt":"2024-10-04T00:26:40","slug":"centos-7-2-%e5%ae%89%e8%a3%9d-nginx-1-13-6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42898\/","title":{"rendered":"CentOS 7.2 \u5b89\u88dd Nginx 1.13.6"},"content":{"rendered":"<h1 id=\"centos-7-2-%e5%ae%89%e8%a3%9d-nginx-1-13-6-aLFfVlwyiW\">CentOS 7.2 \u5b89\u88dd Nginx 1.13.6<\/h1>\n<p>Nginx \u662f\u4e00\u6b3e\u9ad8\u6548\u80fd\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u975c\u614b\u5167\u5bb9\u7684\u63d0\u4f9b\u3001\u53cd\u5411\u4ee3\u7406\u3001\u8ca0\u8f09\u5747\u8861\u7b49\u5834\u666f\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7.2 \u4e0a\u5b89\u88dd Nginx 1.13.6\uff0c\u4e26\u9032\u884c\u57fa\u672c\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e5%89%8d%e7%bd%ae%e6%ba%96%e5%82%99-aLFfVlwyiW\">\u524d\u7f6e\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7.2 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u5de5\u5177\uff0c\u4ee5\u4fbf\u65bc\u5f8c\u7e8c\u7684\u5b89\u88dd\u904e\u7a0b\uff1a<\/p>\n<pre><code>sudo yum install -y epel-release<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-aLFfVlwyiW\">\u5b89\u88dd Nginx<\/h2>\n<p>\u8981\u5b89\u88dd\u7279\u5b9a\u7248\u672c\u7684 Nginx\uff0c\u60a8\u9700\u8981\u5148\u6dfb\u52a0 Nginx \u7684\u5b98\u65b9\u5b58\u5132\u5eab\u3002\u5275\u5efa\u4e00\u500b\u65b0\u7684 repo \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/yum.repos.d\/nginx.repo<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[nginx]\nname=nginx repo\nbaseurl=http:\/\/nginx.org\/packages\/centos\/7\/x86_64\/\ngpgcheck=0\nenabled=1<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Nginx 1.13.6\uff1a<\/p>\n<pre><code>sudo yum install -y nginx-1.13.6<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-nginx-aLFfVlwyiW\">\u555f\u52d5 Nginx<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Nginx \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Nginx \u7684\u904b\u884c\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status nginx<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae%e9%98%b2%e7%81%ab%e7%89%86-aLFfVlwyiW\">\u914d\u7f6e\u9632\u706b\u7246<\/h2>\n<p>\u5982\u679c\u60a8\u7684\u7cfb\u7d71\u555f\u7528\u4e86\u9632\u706b\u7246\uff0c\u60a8\u9700\u8981\u5141\u8a31 HTTP \u548c HTTPS \u6d41\u91cf\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u958b\u653e\u76f8\u61c9\u7684\u7aef\u53e3\uff1a<\/p>\n<pre><code>sudo firewall-cmd --permanent --add-service=http\nsudo firewall-cmd --permanent --add-service=https\nsudo firewall-cmd --reload<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-nginx-%e5%ae%89%e8%a3%9d-aLFfVlwyiW\">\u6e2c\u8a66 Nginx \u5b89\u88dd<\/h2>\n<p>\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165\u60a8\u7684\u4f3a\u670d\u5668 IP \u5730\u5740\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230 Nginx \u7684\u6b61\u8fce\u9801\u9762\uff0c\u9019\u8868\u793a Nginx \u5df2\u7d93\u6210\u529f\u5b89\u88dd\u4e26\u904b\u884c\u3002<\/p>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e9%85%8d%e7%bd%ae-aLFfVlwyiW\">\u57fa\u672c\u914d\u7f6e<\/h2>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u7de8\u8f2f Nginx \u7684\u914d\u7f6e\u6587\u4ef6\u4f86\u9032\u884c\u9032\u4e00\u6b65\u7684\u8a2d\u7f6e\u3002\u914d\u7f6e\u6587\u4ef6\u4f4d\u65bc \/etc\/nginx\/nginx.conf\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u4fee\u6539\u4f3a\u670d\u5668\u540d\u7a31\u3001\u7aef\u53e3\u3001\u6839\u76ee\u9304\u7b49\u8a2d\u7f6e\u3002\u5b8c\u6210\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6\u7684\u6b63\u78ba\u6027\uff1a<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u60a8\u53ef\u4ee5\u91cd\u65b0\u52a0\u8f09 Nginx \u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl reload nginx<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-aLFfVlwyiW\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7.2 \u4e0a\u5b89\u88dd Nginx 1.13.6\uff0c\u4e26\u9032\u884c\u57fa\u672c\u914d\u7f6e\u3002Nginx \u662f\u4e00\u6b3e\u529f\u80fd\u5f37\u5927\u7684\u4f3a\u670d\u5668\uff0c\u9069\u5408\u7528\u65bc\u5404\u7a2e\u7db2\u9801\u61c9\u7528\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684 Nginx \u4f3a\u670d\u5668\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\u3002\u6211\u5011\u63d0\u4f9b\u9ad8\u6548\u80fd\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\uff0c\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install Nginx 1.13.6 on CentOS 7.2 with this step-by-step guide, ensuring optimal performance for your web server setup.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42898","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42898"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42898\/revisions"}],"predecessor-version":[{"id":42899,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42898\/revisions\/42899"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}