{"id":12064,"date":"2020-12-02T14:50:35","date_gmt":"2020-12-02T06:50:35","guid":{"rendered":"https:\/\/www.microfusion.cloud\/hk\/?p=12064"},"modified":"2025-01-13T14:38:34","modified_gmt":"2025-01-13T06:38:34","slug":"gcp-gce-nginx-20201202","status":"publish","type":"post","link":"https:\/\/www.microfusion.cloud\/hk\/2020\/12\/02\/gcp-gce-nginx-20201202\/","title":{"rendered":"\u5982\u4f55\u5728 Google Compute Engine \u4e0a\u5b89\u88dd Nginx Web Server"},"content":{"rendered":"\u76ee\u524d\u4e3b\u6d41\u7684Web Server \u7d04\u53ef\u5206\u70baApache \u548cNginx\u5169\u7a2e\u985e\u578b\uff0cNginx\u5177\u6709\u300c\u5360\u7528\u8cc7\u6e90\u5c11\u300d\u4ee5\u53ca\u300c\u9ad8\u6d41\u91cf\u72c0\u614b\u4e0b\u8868\u73fe\u8f03\u512a\u300d\u7b49\u512a\u9ede\uff0c\u672c\u7bc7\u6587\u7ae0\u8aaa\u660e\u5982\u4f55\u5728 Google Compute Engine \u8a2d\u5b9a VM \u57f7\u884c\u500b\u9ad4\uff0c\u5c07\u65bc\u4f5c\u696d\u7cfb\u7d71 Ubuntu 18.04 \u4e2d\u5b89\u88dd Nginx web server\u3002\n<h2>\u6d41\u7a0b\u5927\u7db1<\/h2>\n1. \u9078\u64c7\u5c08\u6848\n2. \u5efa\u7acb\u57f7\u884c\u500b\u9ad4\n3. \u586b\u5165\u57f7\u884c\u500b\u9ad4\u8cc7\u8a0a\n4. \u74b0\u5883\u5b89\u88dd\n5. \u8a2a\u554fNginx \u7684\u9810\u8a2d\u9996\u9801\n<h2>\u5be6\u4f5c<\/h2>\n<h3><strong>1. \u9078\u64c7\u5c08\u6848<\/strong><\/h3>\n\u5728GCP\u7684 Concole \u9801\u9762\u4e0a\u9078\u64c7\u60a8\u8981\u5efa\u7acb VM \u7684\u5c08\u6848\uff0c\u82e5\u7121\u5c08\u6848\u5247\u65b0\u5efa\u4e00\u500b\u5c08\u6848\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01-1024x78.jpg\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01-1024x78.jpg 1024w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01-300x23.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01-768x59.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01-600x46.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/01.jpg 1073w\" alt=\"\" width=\"1024\" height=\"78\" \/><\/p>\n\n<h3><strong>2. \u5efa\u7acb\u57f7\u884c\u500b\u9ad4<\/strong><\/h3>\n\u9ede\u9078\u5728Console\u9801\u9762\u5de6\u4e0a\u65b9\u7684\u5c0e\u89bd\u9078\u55ae\uff0c\u6e38\u6a19\u79fb\u52d5\u5230\u904b\u7b97\u5206\u985e\u4e2d\u7684<strong>Compute Engine \u2192 VM instance \u2192\u00a0 Create instance <\/strong><strong>\u5efa\u7acb\u57f7\u884c\u500b\u9ad4<\/strong>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02-782x1024.jpg\" sizes=\"auto, (max-width: 782px) 100vw, 782px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02-782x1024.jpg 782w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02-229x300.jpg 229w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02-768x1005.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02-600x785.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/02.jpg 920w\" alt=\"\" width=\"782\" height=\"1024\" \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03-1024x368.jpg\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03-1024x368.jpg 1024w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03-300x108.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03-768x276.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03-600x215.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/03.jpg 1170w\" alt=\"\" width=\"1024\" height=\"368\" \/><\/p>\n\n<h3><strong>3. \u586b\u5165\u57f7\u884c\u500b\u9ad4\u8cc7\u8a0a<\/strong><\/h3>\n\u586b\u5165\u60a8\u8981\u7684\u57f7\u884c\u500b\u9ad4\u540d\u7a31\uff0c\u4ee5\u53ca\u60a8\u5e0c\u671bVM\u57f7\u884c\u500b\u9ad4\u6240\u5728\u7684<em>\u5340\u57df<\/em>\u3001\u6a5f\u5668\u985e\u578b\u7b49\u8cc7\u8a0a\uff0c\u5b8c\u6210\u5f8c\u9ede\u64ca <strong>Create<\/strong> \u5efa\u7acb\u57f7\u884c\u500b\u9ad4\n\n<strong>\u672c\u6587\u4ee5\u4e0b\u65b9\u898f\u683c\u4f5c\u70ba\u7bc4\u4f8b\uff1a<\/strong>\n<ul>\n \t<li><strong>Region<\/strong>: <strong>asia-east1 (Taiwan)<\/strong> ; <strong>Zone<\/strong>: <strong>asia-east1-a<\/strong><\/li>\n \t<li><strong>Machine type (<\/strong><strong>\u6a5f\u5668\u985e\u578b<\/strong><strong>): e2-micro (2 vCpu, 1GB memory )<\/strong><\/li>\n \t<li><strong>Boot disk (<\/strong><strong>\u958b\u6a5f\u78c1\u789f<\/strong><strong>): Ubuntu 18.04LTS<\/strong><\/li>\n<\/ul>\n\u5141\u8a31\u6240\u6709\u7684 <strong>Cloud APIs<\/strong>\n<ul>\n \t<li><strong>Identity and API access: Allow full access to all Cloud APIs<\/strong><\/li>\n<\/ul>\n\u8a2d\u5b9a\u9632\u706b\u7246\uff0c\u5141\u8a31<strong>HTTP<\/strong>\u3001<strong>HTTPS <\/strong><strong>\u6d41\u91cf<\/strong>\n\n<strong>Firewall: Check Allow HTTP traffic &amp; Allow HTTPS traffic<\/strong>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/04.jpg\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/04.jpg 808w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/04-269x300.jpg 269w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/04-768x855.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/04-600x668.jpg 600w\" alt=\"\" width=\"808\" height=\"900\" \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/05.jpg\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/05.jpg 809w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/05-300x242.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/05-768x620.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/05-600x484.jpg 600w\" alt=\"\" width=\"809\" height=\"653\" \/><\/p>\n\n<h3><strong>4. \u74b0\u5883\u5b89\u88dd<\/strong><\/h3>\n\u5728GCP Console\u9801\u9762\u9ede\u9078\u81f3<strong>VM\u57f7\u884c\u500b\u9ad4<\/strong>\uff0c\u5728\u5217\u8868\u4e2d\u9ede\u9078 \u9023\u7dda\u81f3\u60a8\u7684VM\u57f7\u884c\u500b\u9ad4\u3002\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06-1024x90.jpg\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06-1024x90.jpg 1024w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06-300x26.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06-768x67.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06-600x53.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/06.jpg 1074w\" alt=\"\" width=\"1024\" height=\"90\" \/><\/p>\n\n<h3><strong>5. \u9032\u5165 Linux server \u5f8c\uff0c\u8f38\u5165\u4ee5\u4e0b\u6307\u4ee4\u9032\u884c\u5b89\u88dd\u5957\u4ef6\u3001\u6e05\u55ae\u66f4\u65b0<\/strong><\/h3>\n<strong><em>sudo apt update\n<\/em><\/strong>\n\u8f38\u5165\u4ee5\u4e0b\u6307\u4ee4\u9032\u884c Nginx server \u7684\u5b89\u88dd\n<strong><em>sudo apt install nginx<\/em><\/strong>\n\n\u57f7\u884c\u4ee5\u4e0b\u6307\u4ee4\u78ba\u8a8d Nginx Server \u7576\u524d\u72c0\u614b\n<strong><em>systemctl status nginx<\/em><\/strong>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07-1024x267.jpg\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07-1024x267.jpg 1024w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07-300x78.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07-768x200.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07-600x157.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/07.jpg 1073w\" alt=\"\" width=\"1024\" height=\"267\" \/><\/p>\n\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u53ef\u7528\u7684 Nginx ufw \u914d\u7f6e\u6587\u4ef6:\nsudo ufw app list\n\n<strong>Output:\n<\/strong><sup>Available applications: Nginx Full Nginx HTTP Nginx HTTPS OpenSSH<\/sup>\n<h3><strong>6. \u8a2a\u554fNginx \u7684\u9810\u8a2d\u9996\u9801<\/strong><\/h3>\n\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 VM \u57f7\u884c\u500b\u9ad4\u7684\u5916\u90e8IP\n\n\u82e5\u770b\u5230\u4ee5\u4e0b Nginx \u7684\u9810\u8a2d\u9996\u9801\uff0c\u5373\u4ee3\u8868\u6210\u529f\u5b89\u88dd\u60a8\u7684 Nginx server \u4e26\u5df2\u555f\u52d5\u5c0d\u5916\u670d\u52d9\u3002\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08-1024x473.jpg\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08-1024x473.jpg 1024w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08-300x139.jpg 300w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08-768x355.jpg 768w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08-600x277.jpg 600w, https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/12\/08.jpg 1134w\" alt=\"\" width=\"1024\" height=\"473\" \/><\/p>\n<p style=\"text-align: center;\">\u770b\u5b8c\u6e05\u695a\u7c21\u55ae\u53c8\u5feb\u901f\u7684\u6559\u5b78\uff0c\u5c31\u53ef\u4ee5\u4f86\u8a66\u8a66\u770b\u00a0 Nginx Web Server \u5566~<\/p>\n<p style=\"text-align: center;\">\u82e5\u60f3\u4e86\u89e3\u5b8c\u6574\u61c9\u7528\uff0c\u8acb\u6301\u7e8c\u95dc\u6ce8<a href=\"https:\/\/www.microfusion.cloud\/hk\/blog\/\">\u5b8f\u5ead\u67b6\u69cb\u5e2b\u5c08\u6b04<\/a>\uff0c\u82e5\u6709\u4efb\u4f55 \u96f2\u7aef\u9700\u6c42\uff0c\u4e5f\u6b61\u8fce\u96a8\u6642\u8207\u6211\u5011\u806f\u7e6b\u5594!<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.microfusion.cloud\/hk\/contact\/\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mf-web-plugin-hk.storage.googleapis.com\/wp-content\/uploads\/2020\/02\/%E8%81%AF%E7%B5%A1%E6%88%91%E5%80%91.png\" alt=\"\" width=\"185\" height=\"103\" \/><\/a><\/p>\n<!-- \/wp:post-content -->","protected":false},"excerpt":{"rendered":"<p>\u76ee\u524d\u4e3b\u6d41\u7684Web Server \u7d04\u53ef\u5206\u70baApache \u548cNginx\u5169\u7a2e\u985e\u578b\uff0cNginx\u5177\u6709\u300c\u5360\u7528\u8cc7\u6e90\u5c11\u300d\u4ee5\u53ca\u300c [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":12091,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[173],"tags":[199],"class_list":["post-12064","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical_gcp","tag-gcp"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/12064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/comments?post=12064"}],"version-history":[{"count":13,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/12064\/revisions"}],"predecessor-version":[{"id":20573,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/posts\/12064\/revisions\/20573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/media\/12091"}],"wp:attachment":[{"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/media?parent=12064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/categories?post=12064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microfusion.cloud\/hk\/wp-json\/wp\/v2\/tags?post=12064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}