
有沒有辦法讓 OPcache 使用哈希或針對每個網域上的特定目錄來停用 use_pwd,這樣它就不會一遍又一遍地快取相同的套件?
預設情況下,OPcache 將工作目錄附加到腳本鍵以防止衝突。這可以透過以下方式切換opcache.use_cwd設置,但在具有多個網站的伺服器上並不是很有用,因為 php 設定檔會發生衝突。
背景 我有多個 Symfony、Magento 2 等。在同一伺服器上執行的應用程式中,供應商目錄佔所有 PHP 程式碼的 95%,這些應用程式會在 OPcache 中建立許多重複檔案。
答案1
是的,在您的 opcache.config 上啟用以下選項:
; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
opcache.use_cwd=1