PHP5.6+7代碼效能加速-開啟Zend OPcache-最佳化CPU

來源:互聯網
上載者:User

標籤:zend   request   common   val   版本   fas   cli   技術分享   eval   

說明

PHP 5.5+版本以上的,可以使用PHP內建的opcache開啟效能加速(預設是關閉的)。對於PHP 5.5以下版本的,需要使用APC加速,這裡不說明,可以自行上網搜尋PHP APC加速的方法。

 

 

PHP開啟opcache方法

1、開啟php.ini檔案(如果centos的/usr/local/lib目錄下沒有php.ini,那麼從php解壓後源檔案中複製一個過去,比如:php.ini-production)

2、找到:[opcache],設定為:

[opcache]; dll地址zend_extension=php_opcache.dll; 開關開啟opcache.enable=1; 開啟CLIopcache.enable_cli=1; 可用記憶體, 酌情而定, 單位為:Mbopcache.memory_consumption=528; Zend Optimizer + 暫存池中字串的占記憶體總量.(單位:MB)opcache.interned_strings_buffer=8; 對多快取檔案限制, 命中率不到 100% 的話, 可以試著提高這個值opcache.max_accelerated_files=10000; Opcache 會在一定時間內去檢查檔案的修改時間, 這裡設定檢查的時間周期, 預設為 2, 定位為秒opcache.revalidate_freq=1; 開啟快速關閉, 開啟這個在PHP Request Shutdown的時候回收記憶體的速度會提高opcache.fast_shutdown=1

PHP5.6+7代碼效能加速-開啟Zend OPcache-最佳化CPU

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.