{"id":35370,"date":"2024-09-30T23:56:53","date_gmt":"2024-09-30T15:56:53","guid":{"rendered":"https:\/\/server.hk\/cnblog\/35370\/"},"modified":"2024-09-30T23:56:54","modified_gmt":"2024-09-30T15:56:54","slug":"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_http2%e6%94%af%e6%8c%81http-2%e5%8d%94%e8%ad%b0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/35370\/","title":{"rendered":"Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_http2\u652f\u6301HTTP\/2\u5354\u8b70"},"content":{"rendered":"<h1 id=\"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_http2%e6%94%af%e6%8c%81http-2%e5%8d%94%e8%ad%b0-lmNgsMqApn\">Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_http2\u652f\u6301HTTP\/2\u5354\u8b70<\/h1>\n<p>\u96a8\u8457\u7db2\u969b\u7db2\u8def\u7684\u767c\u5c55\uff0c\u7db2\u7ad9\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002HTTP\/2\u5354\u8b70\u4f5c\u70baHTTP\/1.1\u7684\u5347\u7d1a\u7248\uff0c\u63d0\u4f9b\u4e86\u66f4\u5feb\u7684\u52a0\u8f09\u901f\u5ea6\u548c\u66f4\u9ad8\u7684\u6548\u7387\u3002Apache\u4f5c\u70ba\u6700\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\u4e4b\u4e00\uff0c\u901a\u904emod_http2\u6a21\u7d44\u652f\u6301HTTP\/2\u5354\u8b70\uff0c\u70ba\u7db2\u7ad9\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5728Apache\u4e2d\u555f\u7528mod_http2\uff0c\u4e26\u4ecb\u7d39\u76f8\u95dc\u7684\u5b89\u5168\u7b56\u7565\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afhttp-2%ef%bc%9f-lmNgsMqApn\">\u4ec0\u9ebc\u662fHTTP\/2\uff1f<\/h2>\n<p>HTTP\/2\u662f\u7531IETF\u65bc2015\u5e74\u6b63\u5f0f\u767c\u5e03\u7684\u7db2\u8def\u5354\u8b70\uff0c\u65e8\u5728\u63d0\u9ad8\u7db2\u9801\u52a0\u8f09\u901f\u5ea6\u548c\u6548\u7387\u3002\u8207HTTP\/1.1\u76f8\u6bd4\uff0cHTTP\/2\u5f15\u5165\u4e86\u591a\u8def\u5fa9\u7528\u3001\u982d\u90e8\u58d3\u7e2e\u548c\u4f3a\u670d\u5668\u63a8\u9001\u7b49\u7279\u6027\uff0c\u9019\u4e9b\u7279\u6027\u4f7f\u5f97\u591a\u500b\u8acb\u6c42\u53ef\u4ee5\u5728\u540c\u4e00\u9023\u63a5\u4e2d\u540c\u6642\u9032\u884c\uff0c\u5f9e\u800c\u6e1b\u5c11\u5ef6\u9072\u548c\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87mod_http2%ef%bc%9f-lmNgsMqApn\">\u70ba\u4ec0\u9ebc\u9078\u64c7mod_http2\uff1f<\/h2>\n<p>Apache\u7684mod_http2\u6a21\u7d44\u63d0\u4f9b\u4e86\u5c0dHTTP\/2\u7684\u652f\u6301\uff0c\u4e26\u4e14\u8207\u73fe\u6709\u7684Apache\u914d\u7f6e\u517c\u5bb9\u3002\u4f7f\u7528mod_http2\u7684\u4e3b\u8981\u512a\u52e2\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u6027\u80fd\u63d0\u5347\uff1a<\/strong>\u901a\u904e\u591a\u8def\u5fa9\u7528\uff0c\u6e1b\u5c11\u4e86\u7db2\u9801\u52a0\u8f09\u6642\u9593\u3002<\/li>\n<li><strong>\u66f4\u597d\u7684\u8cc7\u6e90\u5229\u7528\uff1a<\/strong>\u6e1b\u5c11\u4e86TCP\u9023\u63a5\u7684\u6578\u91cf\uff0c\u964d\u4f4e\u4e86\u4f3a\u670d\u5668\u7684\u8ca0\u64d4\u3002<\/li>\n<li><strong>\u5b89\u5168\u6027\u589e\u5f37\uff1a<\/strong>HTTP\/2\u901a\u5e38\u8207TLS\u4e00\u8d77\u4f7f\u7528\uff0c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8apache%e4%b8%ad%e5%95%9f%e7%94%a8mod_http2-lmNgsMqApn\">\u5982\u4f55\u5728Apache\u4e2d\u555f\u7528mod_http2<\/h2>\n<p>\u8981\u5728Apache\u4e2d\u555f\u7528mod_http2\uff0c\u60a8\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e7%a2%ba%e8%aa%8dapache%e7%89%88%e6%9c%ac-lmNgsMqApn\">1. \u78ba\u8a8dApache\u7248\u672c<\/h3>\n<p>\u9996\u5148\uff0c\u78ba\u4fdd\u60a8\u7684Apache\u7248\u672c\u652f\u6301mod_http2\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5Apache\u7248\u672c\uff1a<\/p>\n<pre><code>apache2 -v<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9dmod_http2%e6%a8%a1%e7%b5%84-lmNgsMqApn\">2. \u5b89\u88ddmod_http2\u6a21\u7d44<\/h3>\n<p>\u5728\u5927\u591a\u6578Linux\u767c\u884c\u7248\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88ddmod_http2\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo a2enmod http2<\/code><\/pre>\n<h3 id=\"3-%e9%85%8d%e7%bd%aeapache%e4%bb%a5%e6%94%af%e6%8c%81http-2-lmNgsMqApn\">3. \u914d\u7f6eApache\u4ee5\u652f\u6301HTTP\/2<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u7de8\u8f2fApache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u555f\u7528HTTP\/2\u652f\u6301\u3002\u6253\u958b\u60a8\u7684Apache\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u65bc\/etc\/apache2\/sites-available\/000-default.conf\uff09\uff0c\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:443&gt;\n    Protocols h2 http\/1.1\n    ...\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>\u9019\u6a23\u914d\u7f6e\u5f8c\uff0cApache\u5c07\u652f\u6301HTTP\/2\u5354\u8b70\u3002<\/p>\n<h3 id=\"4-%e9%87%8d%e5%95%9fapache%e4%bc%ba%e6%9c%8d%e5%99%a8-lmNgsMqApn\">4. \u91cd\u555fApache\u4f3a\u670d\u5668<\/h3>\n<p>\u6700\u5f8c\uff0c\u91cd\u555fApache\u4f3a\u670d\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h2 id=\"apache%e7%9a%84%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5-lmNgsMqApn\">Apache\u7684\u5b89\u5168\u7b56\u7565<\/h2>\n<p>\u5728\u555f\u7528mod_http2\u5f8c\uff0c\u60a8\u9084\u9700\u8981\u8003\u616e\u4e00\u4e9b\u5b89\u5168\u7b56\u7565\uff0c\u4ee5\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u4e0d\u53d7\u653b\u64ca\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u4f7f\u7528TLS\u52a0\u5bc6\uff1a<\/strong>HTTP\/2\u901a\u5e38\u8207TLS\u4e00\u8d77\u4f7f\u7528\uff0c\u78ba\u4fdd\u60a8\u7684\u7db2\u7ad9\u4f7f\u7528HTTPS\u5354\u8b70\u3002<\/li>\n<li><strong>\u5b9a\u671f\u66f4\u65b0Apache\uff1a<\/strong>\u4fdd\u6301Apache\u548c\u6240\u6709\u6a21\u7d44\u7684\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u9632\u6b62\u5df2\u77e5\u6f0f\u6d1e\u7684\u5229\u7528\u3002<\/li>\n<li><strong>\u914d\u7f6e\u9632\u706b\u7246\uff1a<\/strong>\u4f7f\u7528\u9632\u706b\u7246\u4f86\u9650\u5236\u4e0d\u5fc5\u8981\u7684\u6d41\u91cf\uff0c\u4fdd\u8b77\u4f3a\u670d\u5668\u514d\u53d7\u653b\u64ca\u3002<\/li>\n<li><strong>\u76e3\u63a7\u4f3a\u670d\u5668\u65e5\u8a8c\uff1a<\/strong>\u5b9a\u671f\u6aa2\u67e5\u4f3a\u670d\u5668\u65e5\u8a8c\uff0c\u4ee5\u4fbf\u53ca\u65e9\u767c\u73fe\u53ef\u7591\u6d3b\u52d5\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-lmNgsMqApn\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u555f\u7528mod_http2\uff0cApache\u4f3a\u670d\u5668\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u7db2\u7ad9\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002\u96a8\u8457HTTP\/2\u7684\u666e\u53ca\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u7db2\u7ad9\u9078\u64c7\u4f7f\u7528\u9019\u4e00\u5354\u8b70\u4f86\u63d0\u5347\u7528\u6236\u9ad4\u9a57\u3002\u70ba\u4e86\u78ba\u4fdd\u60a8\u7684\u7db2\u7ad9\u5b89\u5168\uff0c\u5efa\u8b70\u9075\u5faa\u4e0a\u8ff0\u5b89\u5168\u7b56\u7565\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3Apache\u5b89\u5168\u7b56\u7565\uff0c\u900f\u904emod_http2\u652f\u6301HTTP\/2\u5354\u8b70\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u5b89\u5168\u6027\uff0c\u78ba\u4fdd\u6578\u64da\u50b3\u8f38\u7684\u5b89\u5168\u8207\u6548\u7387\u3002<\/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-35370","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/35370","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=35370"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/35370\/revisions"}],"predecessor-version":[{"id":35371,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/35370\/revisions\/35371"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=35370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=35370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=35370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}