{"id":30742,"date":"2023-12-22T12:24:35","date_gmt":"2023-12-22T04:24:35","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/"},"modified":"2025-08-12T20:36:37","modified_gmt":"2025-08-12T12:36:37","slug":"php-opcache%e6%80%a7%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/","title":{"rendered":"PHP OPcache\u6027\u80fd"},"content":{"rendered":"<p>\u6d4b\u8bd5\u5728php\u4e2d\u52a0\u5165OPcache\u540e\u6027\u80fd\u4f1a\u6709\u591a\u5927\u6539\u53d8\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">FROM<\/span><span class=\"s\"> centos:centos8<\/span>\r\n\r\n<span class=\"k\">RUN <\/span>dnf module <span class=\"nb\">install<\/span> <span class=\"nt\">-y<\/span> php:7.4\r\n\r\n<span class=\"k\">COPY<\/span><span class=\"s\"> .\/laravel \/app<\/span>\r\n\r\n<span class=\"k\">WORKDIR<\/span><span class=\"s\"> \/app<\/span>\r\n\r\n<span class=\"k\">CMD<\/span><span class=\"s\"> php artisan serve --host='0.0.0.0' --port='80'<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>$ docker build -t php_test . \r\n$ docker run -it --rm -p 8000:80 php_test\r\nphp -v\r\nPHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )\r\nCopyright (c) The PHP Group\r\nZend Engine v3.4.0, Copyright (c) Zend Technologies\r\n<\/code><\/pre>\n<div>\n                            <img decoding=\"async\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d089637434c4406be09bc\/3-0.png\" class='post-images' alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-12-17 12.52.44.png\" title=\"\">\n                        <\/div>\n<h2>\u9996\u5148\uff0c\u5728\u672a\u5b89\u88c5OPcache\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u6d4b\u91cf\u3002<\/h2>\n<p>1\u79d2\u53ef\u4ee5\u5904\u740615.78\u4e2a\u8bf7\u6c42\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ab -c 10 -n 100 http:\/\/localhost:8000\/\r\nThis is ApacheBench, Version 2.3 &lt;$Revision: 1843412 $&gt;\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http:\/\/www.zeustech.net\/\r\nLicensed to The Apache Software Foundation, http:\/\/www.apache.org\/\r\n\r\nBenchmarking localhost (be patient).....done\r\n\r\n\r\nServer Software:        \r\nServer Hostname:        localhost\r\nServer Port:            8000\r\n\r\nDocument Path:          \/\r\nDocument Length:        17473 bytes\r\n\r\nConcurrency Level:      10\r\nTime taken for tests:   6.337 seconds\r\nComplete requests:      100\r\nFailed requests:        0\r\nTotal transferred:      1861900 bytes\r\nHTML transferred:       1747300 bytes\r\nRequests per second:    15.78 [#\/sec] (mean)\r\nTime per request:       633.652 [ms] (mean)\r\nTime per request:       63.365 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          286.95 [Kbytes\/sec] received\r\n\r\nConnection Times (ms)\r\n              min  mean[+\/-sd] median   max\r\nConnect:        0    0   0.1      0       1\r\nProcessing:    80  596 110.3    624     666\r\nWaiting:       80  596 110.4    624     666\r\nTotal:         81  597 110.3    624     666\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n  50%    624\r\n  66%    629\r\n  75%    633\r\n  80%    635\r\n  90%    639\r\n  95%    646\r\n  98%    647\r\n  99%    666\r\n 100%    666 (longest request)\r\n<\/code><\/pre>\n<h2>\u4f7f\u7528OPcache\u8fdb\u884c\u6d4b\u91cf\u3002<\/h2>\n<p>\u5b89\u88c5Opcache\u3002\u5b89\u88c5\u540e\uff0c\u5728php -v\u547d\u4ee4\u4e2d\u5c06\u663e\u793aZend OPcache\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">FROM<\/span><span class=\"s\"> centos:centos8<\/span>\r\n\r\n<span class=\"k\">RUN <\/span>dnf module <span class=\"nb\">install<\/span> <span class=\"nt\">-y<\/span> php:7.4\r\n<span class=\"k\">RUN <\/span>dnf <span class=\"nb\">install <\/span>php-opcache <span class=\"nt\">-y<\/span>\r\n\r\n<span class=\"k\">COPY<\/span><span class=\"s\"> .\/laravel \/app<\/span>\r\n\r\n<span class=\"k\">WORKDIR<\/span><span class=\"s\"> \/app<\/span>\r\n\r\n<span class=\"k\">CMD<\/span><span class=\"s\"> php artisan serve --host='0.0.0.0' --port='80'<\/span>\r\n\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>[root@9dcc11702f34 app]# php -v\r\nPHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )\r\nCopyright (c) The PHP Group\r\nZend Engine v3.4.0, Copyright (c) Zend Technologies\r\n    with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies\r\n<\/code><\/pre>\n<p>\u5728\u4e00\u79d2\u949f\u5185\u6210\u529f\u5904\u7406107.10\u4e2a\u8bf7\u6c42\u3002<\/p>\n<pre class=\"post-pre\"><code>ab -c 10 -n 100 http:\/\/localhost:8000\/ \r\nThis is ApacheBench, Version 2.3 &lt;$Revision: 1843412 $&gt;\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http:\/\/www.zeustech.net\/\r\nLicensed to The Apache Software Foundation, http:\/\/www.apache.org\/\r\n\r\nBenchmarking localhost (be patient).....done\r\n\r\n\r\nServer Software:        \r\nServer Hostname:        localhost\r\nServer Port:            8000\r\n\r\nDocument Path:          \/\r\nDocument Length:        17473 bytes\r\n\r\nConcurrency Level:      10\r\nTime taken for tests:   0.934 seconds\r\nComplete requests:      100\r\nFailed requests:        0\r\nTotal transferred:      1861900 bytes\r\nHTML transferred:       1747300 bytes\r\nRequests per second:    107.10 [#\/sec] (mean)\r\nTime per request:       93.374 [ms] (mean)\r\nTime per request:       9.337 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          1947.30 [Kbytes\/sec] received\r\n\r\nConnection Times (ms)\r\n              min  mean[+\/-sd] median   max\r\nConnect:        0    0   0.1      0       1\r\nProcessing:     8   72  19.3     73     193\r\nWaiting:        8   72  19.2     73     192\r\nTotal:          9   73  19.2     73     193\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n  50%     73\r\n  66%     78\r\n  75%     82\r\n  80%     84\r\n  90%     87\r\n  95%     89\r\n  98%     90\r\n  99%    193\r\n 100%    193 (longest request)\r\n<\/code><\/pre>\n<h2>\u6574\u7406<\/h2>\n<p>\u5982\u679c\u5bfc\u5165OPcache\uff0c\u901f\u5ea6\u4f1a\u63d0\u9ad8\u5927\u7ea66\u500d\u3002\u7531\u4e8e\u5728docker\u4e2d\u6302\u8f7d\u4f1a\u5bfc\u81f4\u8bfb\u53d6\u53d8\u6162\uff0c\u6240\u4ee5\u901a\u8fc7OPcache\u8fdb\u884c\u8bfb\u53d6\u7f13\u5b58\u53ef\u80fd\u4f1a\u52a0\u5feb\u901f\u5ea6\u3002\u79ef\u6781\u5730\u5b89\u88c5OPcache\u4f3c\u4e4e\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4b\u8bd5\u5728php\u4e2d\u52a0\u5165OPcache\u540e\u6027\u80fd\u4f1a\u6709\u591a\u5927\u6539\u53d8\u3002 FROM centos:centos8 RUN dnf  [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[227],"class_list":["post-30742","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP OPcache\u6027\u80fd - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache\u6027\u80fd\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP OPcache\u6027\u80fd\" \/>\n<meta property=\"og:description\" content=\"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache\u6027\u80fd\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-22T04:24:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-12T12:36:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d089637434c4406be09bc\/3-0.png\" \/>\n<meta name=\"author\" content=\"\u96c5, \u609f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u96c5, \u609f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/\",\"name\":\"PHP OPcache\u6027\u80fd - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-12-22T04:24:35+00:00\",\"dateModified\":\"2025-08-12T12:36:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\"},\"description\":\"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP OPcache\u6027\u80fd\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\",\"name\":\"\u96c5, \u609f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"caption\":\"\u96c5, \u609f\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"PHP OPcache\u6027\u80fd - Blog - Silicon Cloud","description":"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache\u6027\u80fd\/","og_locale":"zh_CN","og_type":"article","og_title":"PHP OPcache\u6027\u80fd","og_description":"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache\u6027\u80fd\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-12-22T04:24:35+00:00","article_modified_time":"2025-08-12T12:36:37+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d089637434c4406be09bc\/3-0.png"}],"author":"\u96c5, \u609f","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u96c5, \u609f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/","name":"PHP OPcache\u6027\u80fd - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-12-22T04:24:35+00:00","dateModified":"2025-08-12T12:36:37+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6"},"description":"\u5173\u4e8ePHP OPcache\u6027\u80fd\u7684\u6280\u672f\u6587\u7ae0","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"PHP OPcache\u6027\u80fd"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6","name":"\u96c5, \u609f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","caption":"\u96c5, \u609f"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php-opcache%e6%80%a7%e8%83%bd\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=30742"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30742\/revisions"}],"predecessor-version":[{"id":50866,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30742\/revisions\/50866"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=30742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=30742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=30742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}