{"id":18010,"date":"2024-11-18T09:58:14","date_gmt":"2024-11-18T01:58:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18010\/"},"modified":"2024-11-18T09:58:14","modified_gmt":"2024-11-18T01:58:14","slug":"nginx%e6%80%8e%e4%b9%88%e8%bf%90%e8%a1%8capache","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18010\/","title":{"rendered":"nginx\u600e\u4e48\u8fd0\u884capache"},"content":{"rendered":"<blockquote><p>\n  \u8981\u8ba9 nginx \u8fd0\u884c apache\uff0c\u9700\u8981\uff1a1. \u5b89\u88c5 nginx \u548c apache\uff1b2. \u914d\u7f6e nginx \u4ee3\u7406\uff1b3. \u542f\u52a8 nginx \u548c apache\uff1b4. \u6d4b\u8bd5\u914d\u7f6e\uff0c\u786e\u4fdd\u8bbf\u95ee\u57df\u540d\u540e\u80fd\u770b\u5230 apache \u5185\u5bb9\u3002\u53e6\u5916\uff0c\u9700\u8981\u6ce8\u610f\u7aef\u53e3\u53f7\u5339\u914d\u3001\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u548c ssl\/tls \u8bbe\u7f6e\u7b49\u5176\u4ed6\u4e8b\u9879\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052717542316369.jpg\" class=\"aligncenter\" title=\"nginx\u600e\u4e48\u8fd0\u884capache\u63d2\u56fe\" alt=\"nginx\u600e\u4e48\u8fd0\u884capache\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 Nginx \u8fd0\u884c Apache<\/strong><\/p>\n<p><strong>\u5982\u4f55\u8ba9 Nginx \u8fd0\u884c Apache\uff1f<\/strong><\/p>\n<p>\u8981\u4f7f Nginx \u8fd0\u884c Apache\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>\u5b89\u88c5 Nginx \u548c Apache<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Nginx \u548c Apache\uff1a<\/p>\n<pre># \u5bf9\u4e8e Debian\/Ubuntu\uff1a\nsudo apt install nginx apache2\n\n# \u5bf9\u4e8e CentOS\/RHEL\uff1a\nsudo yum install nginx httpd<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u914d\u7f6e Nginx \u4ee3\u7406<\/strong><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u914d\u7f6e Nginx \u4f5c\u4e3a Apache \u7684\u53cd\u5411\u4ee3\u7406\u3002\u7f16\u8f91 Nginx \u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4e3a \/etc\/\/sites-available\/default\uff09\uff1a<\/p>\n<pre>server {\n    listen 80;\n    server_name example.com;\n\n    location \/ {\n        proxy_pass http:\/\/localhost:8080;\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 &#8220;example.com&#8221; \u66ff\u6362\u4e3a\u670d\u52a1\u5668\u7684\u5b9e\u9645\u57df\u540d\u3002<\/li>\n<li>\u5c06 &#8220;8080&#8221; \u66ff\u6362\u4e3a Apache \u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002<\/li>\n<\/ul>\n<p><strong>\u542f\u52a8 Nginx \u548c Apache<\/strong><\/p>\n<p>\u542f\u52a8 Nginx \u548c Apache\uff1a<\/p>\n<pre># \u542f\u52a8 Nginx\nsudo service nginx start\n\n# \u542f\u52a8 Apache\nsudo service apache2 start<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6d4b\u8bd5\u914d\u7f6e<\/strong><\/p>\n<p>\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u57df\u540d\uff08\u4f8b\u5982 &#8220;example.com&#8221;\uff09\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u770b\u5230 Apache \u63d0\u4f9b\u7684\u5185\u5bb9\u3002<\/p>\n<p><strong>\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li> <strong>\u7aef\u53e3\u53f7\uff1a<\/strong>\u786e\u4fdd Apache \u76d1\u542c\u7684\u7aef\u53e3\u4e0e Nginx \u4ee3\u7406\u4e2d\u6307\u5b9a\u7684\u7aef\u53e3\u53f7\u5339\u914d\u3002<\/li>\n<li> <strong>\u865a\u62df\u4e3b\u673a\uff1a<\/strong>\u5982\u679c\u4f7f\u7528 Apache \u7684\u865a\u62df\u4e3b\u673a\uff0c\u9700\u8981\u5728 Nginx \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u4ee3\u7406\u89c4\u5219\u6765\u9002\u5e94\u5b83\u4eec\u3002<\/li>\n<li> <strong>SSL\/TLS\uff1a<\/strong>\u5982\u679c\u9700\u8981\u901a\u8fc7 HTTPS \u8bbf\u95ee Apache\uff0c\u9700\u8981\u5728 Nginx \u4e2d\u914d\u7f6e SSL\/TLS \u8bc1\u4e66\u548c\u91cd\u5b9a\u5411\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fd0\u884c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u8ba9 nginx \u8fd0\u884c apache\uff0c\u9700\u8981\uff1a1. \u5b89\u88c5 nginx \u548c apache\uff1b2. \u914d\u7f6e nginx \u4ee3\u7406\uff1b3. \u542f\u52a8 nginx \u548c apache\uff1b4. \u6d4b\u8bd5\u914d\u7f6e\uff0c\u786e\u4fdd\u8bbf\u95ee\u57df\u540d\u540e\u80fd\u770b\u5230 apache \u5185\u5bb9\u3002\u53e6\u5916\uff0c\u9700\u8981\u6ce8\u610f\u7aef\u53e3\u53f7\u5339\u914d\u3001\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u548c ssl\/tls \u8bbe\u7f6e\u7b49\u5176\u4ed6\u4e8b\u9879\u3002 \u4f7f\u7528 Nginx \u8fd0\u884c Apache \u5982\u4f55\u8ba9 Nginx \u8fd0\u884c Apache\uff1f \u8981\u4f7f Nginx \u8fd0\u884c Apache\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u5b89\u88c5 Nginx \u548c Apache \u9996\u5148\uff0c\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Nginx \u548c Apache\uff1a # \u5bf9\u4e8e Debian\/Ubuntu\uff1a sudo apt install nginx apache2 # \u5bf9\u4e8e CentOS\/RHEL\uff1a sudo yum install nginx [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18010","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18010"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18010\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}