{"id":48274,"date":"2024-12-02T17:14:23","date_gmt":"2024-12-02T09:14:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48274\/"},"modified":"2024-12-02T17:14:23","modified_gmt":"2024-12-02T09:14:23","slug":"php-%e5%87%bd%e6%95%b0%e7%bc%93%e5%ad%98%e6%8a%80%e6%9c%af%e8%af%a6%e8%a7%a3%ef%bc%9a%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e5%87%bd%e6%95%b0%e7%bc%93%e5%ad%98%e6%8a%80%e6%9c%af%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48274\/","title":{"rendered":"php \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>php \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aphp \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f\u300b<\/span>\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span><\/span>\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p>\u51fd\u6570\u7f13\u5b58\u6280\u672f\u901a\u8fc7\u5c06\u51fd\u6570\u8c03\u7528\u7ed3\u679c\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u63d0\u9ad8\u51fd\u6570\u6267\u884c\u6548\u7387\u3002PHP \u4e2d\u53ef\u4f7f\u7528 Opcache \u6216 APC \u5b9e\u73b0\u51fd\u6570\u7f13\u5b58\u3002\u5177\u4f53\u5b9e\u6218\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 Opcache\/APC\u3001\u914d\u7f6e\u7f13\u5b58\u8bbe\u7f6e\uff0c\u542f\u7528\u6587\u4ef6\u66f4\u6539\u76d1\u63a7\u7b49\u3002\u4f7f\u7528\u65f6\u65e0\u9700\u989d\u5916\u64cd\u4f5c\uff0c\u7f13\u5b58\u673a\u5236\u81ea\u52a8\u751f\u6548\u3002\u9700\u8981\u6ce8\u610f\u51fd\u6570\u7b7e\u540d\u66f4\u6539\u3001\u5bf9\u8c61\u7f13\u5b58\u548c\u6027\u80fd\u6d4b\u8bd5\u7b49\u4e8b\u9879\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241027\/1730007520671dd1e072a3a.jpg\" class=\"aligncenter\" title=\"php \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f\u63d2\u56fe\" alt=\"php \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u4f18\u5316\u5927\u578b\u9879\u76ee\u7684\u5229\u5668<\/strong><\/p>\n<p>\u51fd\u6570\u7f13\u5b58\u6280\u672f\u662f\u4e00\u79cd\u5c06\u51fd\u6570\u8c03\u7528\u7684\u7ed3\u679c\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u4ee5\u4fbf\u540e\u7eed\u8c03\u7528\u65f6\u53ef\u4ee5\u76f4\u63a5\u4ece\u5185\u5b58\u4e2d\u83b7\u53d6\u7ed3\u679c\uff0c\u4ece\u800c\u63d0\u9ad8\u51fd\u6570\u6267\u884c\u6548\u7387\u7684\u6280\u672f\u3002\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u51fd\u6570\u8c03\u7528\u5f80\u5f80\u975e\u5e38\u9891\u7e41\uff0c\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u9879\u76ee\u7684\u6027\u80fd\u3002<\/p>\n<p><strong>\u5b9e\u73b0\u539f\u7406<\/strong><\/p>\n<p>PHP \u4e2d\u6709\u4e24\u79cd\u4e3b\u8981\u7684\u51fd\u6570\u7f13\u5b58\u673a\u5236\uff1a<\/p>\n<ul>\n<li><strong>Opcache\uff1a<\/strong> PHP \u5185\u7f6e\u7684\u51fd\u6570\u7f13\u5b58\u6a21\u5757\uff0c\u901a\u8fc7\u5c06\u7f16\u8bd1\u540e\u7684 PHP \u4ee3\u7801\uff08\u5b57\u8282\u7801\uff09\u5b58\u50a8\u5728\u5171\u4eab\u5185\u5b58\u4e2d\u6765\u5b9e\u73b0\u51fd\u6570\u7f13\u5b58\u3002<\/li>\n<li><strong>APC\uff1a<\/strong> \u4e00\u4e2a\u7b2c\u4e09\u65b9 PHP \u6269\u5c55\uff0c\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u51fd\u6570\u7f13\u5b58\u529f\u80fd\uff0c\u5982\u5bf9\u8c61\u7f13\u5b58\u548c\u7528\u6237\u7f13\u5b58\u3002<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p><strong>\u5b89\u88c5 Opcache<\/strong><\/p>\n<pre># Linux\npecl install opcache\n\n# Windows\npecl install --platform=win32 --extensions=opcache<\/pre>\n<p><strong>\u914d\u7f6e Opcache<\/strong><\/p>\n<pre>; Enable opcache\nopcache.enable=1\n\n; Size of the opcache memory pool\nopcache.memory_consumption=128\n\n; Save compiled scripts in a specific directory\nopcache.compile_only=On\n\n; Enable file change monitoring for cached scripts\nopcache.validate_timestamps=1<\/pre>\n<p><strong>\u5b89\u88c5 APC<\/strong><\/p>\n<pre># Linux\npecl install apc\n\n# Windows\npecl install --platform=win32 --extensions=apc<\/pre>\n<p><strong>\u914d\u7f6e APC<\/strong><\/p>\n<pre>; Enable apc\napc.enabled=1\n\n; Size of the apc memory pool\napc.shm_size=128M\n\n; Cache user-defined functions\napc.cache_by_default=1\n\n; Enable object caching\napc.serializer=php<\/pre>\n<p><strong>\u4f7f\u7528\u51fd\u6570\u7f13\u5b58<\/strong><\/p>\n<p>\u5728\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u65f6\uff0c\u53ea\u9700\u8981\u8c03\u7528\u6b63\u5e38\u7684\u51fd\u6570\u5373\u53ef\uff0c\u65e0\u9700\u8fdb\u884c\u989d\u5916\u7684\u64cd\u4f5c\u3002\u7f13\u5b58\u673a\u5236\u4f1a\u5728\u9700\u8981\u65f6\u81ea\u52a8\u751f\u6548\u3002<\/p>\n<p><strong>\u9700\u8981\u6ce8\u610f\u7684\u70b9<\/strong><\/p>\n<ul>\n<li><strong>\u51fd\u6570\u7b7e\u540d\u66f4\u6539\uff1a<\/strong>\u5982\u679c\u7f13\u5b58\u7684\u51fd\u6570\u7b7e\u540d\u53d1\u751f\u66f4\u6539\uff0c\u5219\u9700\u8981\u6e05\u9664\u7f13\u5b58\u5e76\u5728\u4e0b\u6b21\u8c03\u7528\u65f6\u91cd\u65b0\u7f16\u8bd1\u5b83\u3002<\/li>\n<li><strong>\u5bf9\u8c61\u7f13\u5b58\uff1a<\/strong>\u5982\u679c\u4f7f\u7528 APC \u7684\u5bf9\u8c61\u7f13\u5b58\u529f\u80fd\uff0c\u9700\u8981\u786e\u4fdd\u5bf9\u8c61\u662f\u53ef\u5e8f\u5217\u5316\u7684\u3002<\/li>\n<li><strong>\u6027\u80fd\u6d4b\u8bd5\uff1a<\/strong>\u5728\u542f\u7528\u51fd\u6570\u7f13\u5b58\u540e\uff0c\u52a1\u5fc5\u5bf9\u5176\u6027\u80fd\u8fdb\u884c\u6d4b\u8bd5\uff0c\u4ee5\u9a8c\u8bc1\u5176\u662f\u5426\u5e26\u6765\u7684\u9884\u671f\u6536\u76ca\u3002<\/li>\n<\/ul>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aphp \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f \u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0\u300aphp \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u5982\u4f55\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u4f18\u5316\u5927\u578b\u9879\u76ee\uff1f\u300b\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01 \u51fd\u6570\u7f13\u5b58\u6280\u672f\u901a\u8fc7\u5c06\u51fd\u6570\u8c03\u7528\u7ed3\u679c\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u63d0\u9ad8\u51fd\u6570\u6267\u884c\u6548\u7387\u3002PHP \u4e2d\u53ef\u4f7f\u7528 Opcache \u6216 APC \u5b9e\u73b0\u51fd\u6570\u7f13\u5b58\u3002\u5177\u4f53\u5b9e\u6218\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 Opcache\/APC\u3001\u914d\u7f6e\u7f13\u5b58\u8bbe\u7f6e\uff0c\u542f\u7528\u6587\u4ef6\u66f4\u6539\u76d1\u63a7\u7b49\u3002\u4f7f\u7528\u65f6\u65e0\u9700\u989d\u5916\u64cd\u4f5c\uff0c\u7f13\u5b58\u673a\u5236\u81ea\u52a8\u751f\u6548\u3002\u9700\u8981\u6ce8\u610f\u51fd\u6570\u7b7e\u540d\u66f4\u6539\u3001\u5bf9\u8c61\u7f13\u5b58\u548c\u6027\u80fd\u6d4b\u8bd5\u7b49\u4e8b\u9879\u3002 PHP \u51fd\u6570\u7f13\u5b58\u6280\u672f\u8be6\u89e3\uff1a\u4f18\u5316\u5927\u578b\u9879\u76ee\u7684\u5229\u5668 \u51fd\u6570\u7f13\u5b58\u6280\u672f\u662f\u4e00\u79cd\u5c06\u51fd\u6570\u8c03\u7528\u7684\u7ed3\u679c\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u4ee5\u4fbf\u540e\u7eed\u8c03\u7528\u65f6\u53ef\u4ee5\u76f4\u63a5\u4ece\u5185\u5b58\u4e2d\u83b7\u53d6\u7ed3\u679c\uff0c\u4ece\u800c\u63d0\u9ad8\u51fd\u6570\u6267\u884c\u6548\u7387\u7684\u6280\u672f\u3002\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u51fd\u6570\u8c03\u7528\u5f80\u5f80\u975e\u5e38\u9891\u7e41\uff0c\u4f7f\u7528\u51fd\u6570\u7f13\u5b58\u6280\u672f\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u9879\u76ee\u7684\u6027\u80fd\u3002 \u5b9e\u73b0\u539f\u7406 PHP \u4e2d\u6709\u4e24\u79cd\u4e3b\u8981\u7684\u51fd\u6570\u7f13\u5b58\u673a\u5236\uff1a Opcache\uff1a PHP \u5185\u7f6e\u7684\u51fd\u6570\u7f13\u5b58\u6a21\u5757\uff0c\u901a\u8fc7\u5c06\u7f16\u8bd1\u540e\u7684 PHP \u4ee3\u7801\uff08\u5b57\u8282\u7801\uff09\u5b58\u50a8\u5728\u5171\u4eab\u5185\u5b58\u4e2d\u6765\u5b9e\u73b0\u51fd\u6570\u7f13\u5b58\u3002 APC\uff1a \u4e00\u4e2a\u7b2c\u4e09\u65b9 PHP \u6269\u5c55\uff0c\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u51fd\u6570\u7f13\u5b58\u529f\u80fd\uff0c\u5982\u5bf9\u8c61\u7f13\u5b58\u548c\u7528\u6237\u7f13\u5b58\u3002 \u5b9e\u6218\u6848\u4f8b \u5b89\u88c5 Opcache # Linux pecl install opcache # Windows pecl install &#8211;platform=win32 &#8211;extensions=opcache \u914d\u7f6e Opcache ; Enable opcache opcache.enable=1 ; Size of the opcache memory pool opcache.memory_consumption=128 ; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48274","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48274","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=48274"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48274\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}