{"id":40463,"date":"2024-10-01T13:31:42","date_gmt":"2024-10-01T05:31:42","guid":{"rendered":"https:\/\/server.hk\/cnblog\/40463\/"},"modified":"2024-10-01T13:31:42","modified_gmt":"2024-10-01T05:31:42","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e8%a8%ad%e7%bd%aeapache%e8%88%87mod_brotli","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/40463\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u8a2d\u7f6eApache\u8207mod_brotli"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e8%a8%ad%e7%bd%aeapache%e8%88%87mod_brotli-uiriDKsZhl\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u8a2d\u7f6eApache\u8207mod_brotli<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u7db2\u7ad9\u7684\u52a0\u8f09\u901f\u5ea6\u5c0d\u65bc\u7528\u6236\u9ad4\u9a57\u548cSEO\u6392\u540d\u81f3\u95dc\u91cd\u8981\u3002Apache\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u512a\u5316\u9078\u9805\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u4f7f\u7528mod_brotli\u9032\u884c\u5167\u5bb9\u58d3\u7e2e\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728Apache\u4f3a\u670d\u5668\u4e0a\u8a2d\u7f6emod_brotli\uff0c\u4ee5\u63d0\u9ad8\u7db2\u7ad9\u6027\u80fd\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_brotli%ef%bc%9f-uiriDKsZhl\">\u4ec0\u9ebc\u662fmod_brotli\uff1f<\/h2>\n<p>mod_brotli\u662f\u4e00\u500bApache\u6a21\u7d44\uff0c\u57fa\u65bcGoogle\u958b\u767c\u7684Brotli\u58d3\u7e2e\u7b97\u6cd5\u3002\u8207\u50b3\u7d71\u7684Gzip\u58d3\u7e2e\u76f8\u6bd4\uff0cBrotli\u80fd\u5920\u63d0\u4f9b\u66f4\u9ad8\u7684\u58d3\u7e2e\u6bd4\uff0c\u5f9e\u800c\u6e1b\u5c11\u50b3\u8f38\u7684\u6578\u64da\u91cf\uff0c\u63d0\u5347\u7db2\u7ad9\u7684\u52a0\u8f09\u901f\u5ea6\u3002\u9019\u5c0d\u65bc\u79fb\u52d5\u8a2d\u5099\u548c\u4f4e\u5e36\u5bec\u74b0\u5883\u5c24\u70ba\u91cd\u8981\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dapache%e8%88%87mod_brotli-uiriDKsZhl\">\u5b89\u88ddApache\u8207mod_brotli<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\u7684\u4f3a\u670d\u5668\u4e0a\u5df2\u7d93\u5b89\u88dd\u4e86Apache\u3002\u4ee5\u4e0b\u662f\u5b89\u88ddmod_brotli\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e5%ae%89%e8%a3%9dapache-uiriDKsZhl\">1. \u5b89\u88ddApache<\/h3>\n<pre><code>sudo apt update\nsudo apt install apache2\n<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9dmod_brotli-uiriDKsZhl\">2. \u5b89\u88ddmod_brotli<\/h3>\n<p>\u5728Ubuntu\u7cfb\u7d71\u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88ddmod_brotli\uff1a<\/p>\n<pre><code>sudo apt install libapache2-mod-brotli\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u7528mod_brotli\u6a21\u7d44\uff1a<\/p>\n<pre><code>sudo a2enmod brotli\n<\/code><\/pre>\n<h3 id=\"3-%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95apache-uiriDKsZhl\">3. \u91cd\u65b0\u555f\u52d5Apache<\/h3>\n<p>\u70ba\u4e86\u4f7f\u66f4\u6539\u751f\u6548\uff0c\u8acb\u91cd\u65b0\u555f\u52d5Apache\u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%aemod_brotli-uiriDKsZhl\">\u914d\u7f6emod_brotli<\/h2>\n<p>\u5b89\u88dd\u4e26\u555f\u7528mod_brotli\u5f8c\uff0c\u63a5\u4e0b\u4f86\u9700\u8981\u9032\u884c\u914d\u7f6e\u3002\u6253\u958bApache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u65bc\/etc\/apache2\/apache2.conf\u6216\/etc\/httpd\/conf\/httpd.conf\uff0c\u7136\u5f8c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>&lt;IfModule mod_brotli.c&gt;\n    BrotliCompressionQuality 5\n    AddOutputFilterByType BROTLI_COMPRESS text\/html text\/plain text\/css application\/javascript application\/json application\/xml\n    &lt;FilesMatch \".(js|css|html|xml)$\"&gt;\n        SetOutputFilter BROTLI_COMPRESS\n    &lt;\/FilesMatch&gt;\n&lt;\/IfModule&gt;\n<\/code><\/pre>\n<p>\u5728\u9019\u6bb5\u914d\u7f6e\u4e2d\uff0cBrotliCompressionQuality\u7684\u503c\u7bc4\u570d\u662f0\u523011\uff0c\u6578\u503c\u8d8a\u9ad8\u58d3\u7e2e\u6bd4\u8d8a\u5927\uff0c\u4f46\u6703\u6d88\u8017\u66f4\u591a\u7684CPU\u8cc7\u6e90\u3002\u6839\u64da\u4f60\u7684\u4f3a\u670d\u5668\u6027\u80fd\u548c\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u503c\u3002<\/p>\n<h2 id=\"%e6%b8%ac%e8%a9%a6mod_brotli%e6%98%af%e5%90%a6%e7%94%9f%e6%95%88-uiriDKsZhl\">\u6e2c\u8a66mod_brotli\u662f\u5426\u751f\u6548<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u700f\u89bd\u5668\u7684\u958b\u767c\u8005\u5de5\u5177\u6216\u5728\u7dda\u5de5\u5177\u4f86\u6aa2\u67e5\u7db2\u7ad9\u7684\u97ff\u61c9\u982d\uff0c\u78ba\u8a8d\u662f\u5426\u555f\u7528\u4e86Brotli\u58d3\u7e2e\u3002\u67e5\u770b\u97ff\u61c9\u982d\u4e2d\u7684Content-Encoding\u5b57\u6bb5\uff0c\u61c9\u986f\u793a\u70ba\u201cbr\u201d\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-uiriDKsZhl\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u4f60\u5df2\u7d93\u6210\u529f\u5728Apache\u4f3a\u670d\u5668\u4e0a\u8a2d\u7f6e\u4e86mod_brotli\uff0c\u9019\u5c07\u6709\u52a9\u65bc\u63d0\u9ad8\u7db2\u7ad9\u7684\u52a0\u8f09\u901f\u5ea6\u548c\u6027\u80fd\u3002\u96a8\u8457\u7db2\u7d61\u6d41\u91cf\u7684\u589e\u52a0\uff0c\u512a\u5316\u7db2\u7ad9\u7684\u52a0\u8f09\u6642\u9593\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u6258\u7ba1\u4f60\u7684\u7db2\u7ad9\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u4f60\u63d0\u4f9b\u7a69\u5b9a\u548c\u5feb\u901f\u7684\u4f3a\u670d\u5668\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u8a2d\u7f6eApache\u4f3a\u670d\u5668\u53ca\u555f\u7528mod_brotli\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u52a0\u901f\u9801\u9762\u52a0\u8f09\u901f\u5ea6\u7684\u8a73\u7d30\u65b0\u624b\u6559\u7a0b\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-40463","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/40463","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=40463"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/40463\/revisions"}],"predecessor-version":[{"id":40464,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/40463\/revisions\/40464"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=40463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=40463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=40463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}