{"id":2703,"date":"2025-09-13T16:16:02","date_gmt":"2025-09-13T08:16:02","guid":{"rendered":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/?p=2703"},"modified":"2025-09-15T11:02:30","modified_gmt":"2025-09-15T03:02:30","slug":"http-2","status":"publish","type":"post","link":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2025\/09\/13\/http-2\/","title":{"rendered":"HTTP\/2"},"content":{"rendered":"\n<p>\u7cfb\u7edf\u73af\u5883\uff1a Debian 12 + Apache 2.4.65 + PHP 8.2\uff0c\u90fd\u662f Debian 12 \u9ed8\u8ba4\u7684\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u542f\u52a8 HTTP\/2 \u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4f7f\u80fd http2 \u6a21\u5757\u3001\u7136\u540e\u91cd\u542f apache2 \u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo a2enmod http2<\/pre>\n\n\n\n<p>\u4f46\u662f\u5728\u5904\u7406 MPM\uff08Multi-Processing Module\uff09 \u65f6\u51fa\u73b0\u4ee5\u4e0b\u95ee\u9898\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">The mpm module (prefork.c) is not supported by mod_http2<\/pre>\n\n\n\n<p>Apache \u9ed8\u8ba4\u91c7\u7528 mpm_prefork\uff0c\u9700\u8981\u6539\u7528 mpm_event \u624d\u80fd\u4f7f\u80fd http2\u3002\u5de5\u4f5c\u6a21\u5f0f\u6539\u53d8\u540e\uff0cPHP \u7684\u5de5\u4f5c\u65b9\u5f0f\u4e5f\u9700\u8981\u66f4\u6539\uff0c\u4e0d\u518d\u4f5c\u4e3a apache \u7684\u4e00\u4e2a\u6a21\u5757\u8fd0\u884c\uff0c\u800c\u662f\u72ec\u7acb\u8fd0\u884c\uff0c\u56e0\u6b64\u9700\u8981\u5b89\u88c5 php-fpm \uff08FastCGI Process Manager\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install php-fpm<\/pre>\n\n\n\n<p>Debian 12 \u9ed8\u8ba4\u91c7\u7528 php 8.2 \u7248\u672c\uff0c\u56e0\u6b64\u5b9e\u9645\u5b89\u88c5\u3001\u914d\u7f6e\u7684\u662f php8.2-fpm\u3002<\/p>\n\n\n\n<p>\u5176\u4ed6\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo a2dismod php8.2<br>sudo a2dismod mpm_prefork<br><br>sudo a2enconf php8.2-fpm<br>sudo a2enmod proxy_fcgi setenvif<br>sudo a2enmod mpm_event<br>sudo a2enmod http2<\/pre>\n\n\n\n<p>\u6700\u540e\u91cd\u542f apache2 \u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart apache2<\/pre>\n\n\n\n<p>\u7136\u540e\u53ef\u4ee5\u7528 curl \u6d4b\u8bd5\u670d\u52a1\u5668\u662f\u5426\u91c7\u7528\u4e86HTTP\/2:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -v --http2 -I https:\/\/yourdomain.com<\/pre>\n\n\n\n<p>php-fpm \u4f5c\u4e3a\u7cfb\u7edf\u7684 services \u72ec\u7acb\u542f\u52a8\u548c\u8fd0\u884c\uff0c\u68c0\u67e5 <em>\/lib\/systemd\/system<\/em> \u76ee\u5f55\u53ef\u4ee5\u627e\u5230\u76f8\u5173\u7684\u914d\u7f6e\uff08php8.2-fpm.service\uff09\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 php-fpm \u7684\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl status php8.2-fpm<\/pre>\n\n\n\n<p>php8.2-fpm \u9ed8\u8ba4\u7684\u53c2\u6570\u6709\u70b9\u504f\u5c0f\uff0c\u9700\u8981\u8c03\u6574\uff08\u6bd4\u5982\u8c03\u6574\u4e3a\u9ed8\u8ba4\u503c\u7684 5 \u500d\uff09\u3002\u4fee\u6539 <em>\/etc\/php\/8.2\/fpm\/pool.d\/www.conf<\/em> \u4e2d\u53c2\u6570\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pm.max_children = 25<br>pm.start_servers = 10<br>pm.min_spare_servers = 5<br>pm.max_spare_servers = 15<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7cfb\u7edf\u73af\u5883\uff1a Debian 12 + Apache 2.4.65 + PHP 8.2\uff0c\u90fd\u662f Debian 12 \u9ed8\u8ba4\u7684\u914d\u7f6e\u3002 \u542f\u52a8 HTTP\/2 \u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4f7f&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2025\/09\/13\/http-2\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[89,926,925,924,150,923],"class_list":["post-2703","post","type-post","status-publish","format-standard","hentry","category-53","tag-apache","tag-http2","tag-mpm_event","tag-mpm_prefork","tag-php","tag-php-fpm"],"_links":{"self":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/2703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/comments?post=2703"}],"version-history":[{"count":6,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/2703\/revisions"}],"predecessor-version":[{"id":2710,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/2703\/revisions\/2710"}],"wp:attachment":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/media?parent=2703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/categories?post=2703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/tags?post=2703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}