{"id":33108,"date":"2022-11-05T00:51:33","date_gmt":"2023-01-16T09:43:31","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/"},"modified":"2024-04-28T23:03:27","modified_gmt":"2024-04-28T15:03:27","slug":"centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/","title":{"rendered":"CentOS7 \u4e0a\u914d\u7f6e nginx"},"content":{"rendered":"<p>\u5728CentOS7\u4e0a\u914d\u7f6eNginx\u7684\u6b65\u9aa4\u3002<br \/>\n\u5728CentOS\u4e0a\u5b89\u88c5\u7a33\u5b9a\u7248\u672c\u7684Nginx\u3002<\/p>\n<h1>\u8a2d\u7f6e\u6587\u4ef6<\/h1>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\/etc\/yum.repos.d\/nginx.repo\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u8be5\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>[nginx]\r\nname=nginx repo\r\nbaseurl=http:\/\/nginx.org\/packages\/centos\/7\/$basearch\/\r\ngpgcheck=0\r\nenabled=0\r\n\r\n\r\n#{OS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3}\u7b87\u6240\u306b\u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8a18\u8ff0\r\nbaseurl=http:\/\/nginx.org\/packages\/centos\/{OS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3}\/$basearch\/\r\n<\/code><\/pre>\n<h1>\u5b89\u88c5nginx<\/h1>\n<pre class=\"post-pre\"><code>sudo yum -y --enablerepo=nginx install nginx\r\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5982\u679c\u80fd\u663e\u793a\u7248\u672c\u53f7\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code>nginx -v\r\n\u30fb\r\n\u30fb\r\n\u30fb\r\nnginx version: nginx\/1.12.2\r\n<\/code><\/pre>\n<h1>\u5173\u4e8enginx\u7684\u914d\u7f6e<\/h1>\n<p>\u5907\u4efdnginx\u521d\u59cb\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684{app_name}.conf\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>cp \/etc\/nginx\/conf.d\/default.conf \/etc\/nginx\/conf.d\/default.conf_old\r\ncp \/etc\/nginx\/conf.d\/default.conf \/etc\/nginx\/conf.d\/\uff5bapp_name\uff5d.conf\r\nvi \/etc\/nginx\/conf.d\/\uff5bapp_name\uff5d.conf\r\n<\/code><\/pre>\n<p>\u7f16\u8f91\uff5bapp_name\uff5d.conf\u6587\u4ef6\uff0c\u914d\u7f6e\uff5bapp_name\uff5d\u7684\u8bbe\u7f6e\u3002<br \/>\n\u5c06root\u90e8\u5206\u8bbe\u5b9a\u4e3a\u6587\u6863\u6839\u76ee\u5f55\u3002<\/p>\n<pre class=\"post-pre\"><code>server {\r\n    listen       80;\r\n    server_name \uff5bapp_name\uff5d;\r\n    access_log  \/var\/log\/nginx\/access.log  main;\r\n    error_log   \/var\/log\/nginx\/error.log;\r\n    root \/var\/www\/\uff5bapp_name\uff5d\/public;\r\n\r\n    error_page  404              \/404.html;\r\n    error_page  500 502 503 504  \/50x.html;\r\n}\r\n<\/code><\/pre>\n<h1>\u542f\u52a8nginx<\/h1>\n<p>\u4f7f\u7528&#8221;systemctl status nginx&#8221;\u547d\u4ee4\u53ef\u4ee5\u786e\u8ba4Nginx\u7684\u542f\u52a8\u72b6\u6001\u3002\u5982\u679c\u5b83\u6b63\u5728\u8fd0\u884c\uff0c\u5219\u4f1a\u663e\u793a\u4e3a&#8221;Active&#8221;\u3002\u5982\u679c\u5b83\u6b63\u5728\u8fd0\u884c\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7&#8221;sudo systemctl restart nginx&#8221;\u547d\u4ee4\u91cd\u65b0\u542f\u52a8\uff0c\u5e76\u52a0\u8f7d\u5df2\u914d\u7f6e\u7684\u6587\u4ef6\u3002*\u5982\u679c\u66f4\u6539\u4e86Nginx\u7684\u914d\u7f6e\uff0c\u8bf7\u91cd\u65b0\u542f\u52a8\u5b83\u3002<\/p>\n<pre class=\"post-pre\"><code>#\u72b6\u614b\u78ba\u8a8d\r\nsystemctl status nginx\r\n\r\n#\u8d77\u52d5\r\nsudo systemctl start nginx\r\n\r\n#\u518d\u8d77\u52d5\r\nsudo systemctl restart nginx\r\n\r\n<\/code><\/pre>\n<p>\u53ea\u8981\u80fd\u542f\u52a8\u5e76\u663e\u793a\u5728\u6587\u4ef6\u6839\u76ee\u5f55\u4e0b\u653e\u7f6e\u7684\u6587\u4ef6\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728CentOS7\u4e0a\u914d\u7f6eNginx\u7684\u6b65\u9aa4\u3002 \u5728CentOS\u4e0a\u5b89\u88c5\u7a33\u5b9a\u7248\u672c\u7684Nginx\u3002 \u8a2d\u7f6e\u6587\u4ef6 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\/ [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33108","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CentOS7 \u4e0a\u914d\u7f6e nginx - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-\u4e0a\u914d\u7f6e-nginx\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CentOS7 \u4e0a\u914d\u7f6e nginx\" \/>\n<meta property=\"og:description\" content=\"\u5728CentOS7\u4e0a\u914d\u7f6eNginx\u7684\u6b65\u9aa4\u3002 \u5728CentOS\u4e0a\u5b89\u88c5\u7a33\u5b9a\u7248\u672c\u7684Nginx\u3002 \u8a2d\u7f6e\u6587\u4ef6 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\/ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-\u4e0a\u914d\u7f6e-nginx\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-16T09:43:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T15:03:27+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/\",\"name\":\"CentOS7 \u4e0a\u914d\u7f6e nginx - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-01-16T09:43:31+00:00\",\"dateModified\":\"2024-04-28T15:03:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CentOS7 \u4e0a\u914d\u7f6e nginx\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"CentOS7 \u4e0a\u914d\u7f6e nginx - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-\u4e0a\u914d\u7f6e-nginx\/","og_locale":"zh_CN","og_type":"article","og_title":"CentOS7 \u4e0a\u914d\u7f6e nginx","og_description":"\u5728CentOS7\u4e0a\u914d\u7f6eNginx\u7684\u6b65\u9aa4\u3002 \u5728CentOS\u4e0a\u5b89\u88c5\u7a33\u5b9a\u7248\u672c\u7684Nginx\u3002 \u8a2d\u7f6e\u6587\u4ef6 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\/ [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-\u4e0a\u914d\u7f6e-nginx\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-16T09:43:31+00:00","article_modified_time":"2024-04-28T15:03:27+00:00","author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/","name":"CentOS7 \u4e0a\u914d\u7f6e nginx - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-01-16T09:43:31+00:00","dateModified":"2024-04-28T15:03:27+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"CentOS7 \u4e0a\u914d\u7f6e nginx"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/centos7-%e4%b8%8a%e9%85%8d%e7%bd%ae-nginx\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=33108"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33108\/revisions"}],"predecessor-version":[{"id":63642,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33108\/revisions\/63642"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=33108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=33108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=33108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}