php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71748 Opcache in CLI cannot be enabled
Submitted: 2016-03-09 00:24 UTC Modified: 2016-03-09 00:51 UTC
From: iquito at gmx dot net Assigned:
Status: Closed Package: opcache
PHP Version: 7.0.4 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: iquito at gmx dot net
New email:
PHP Version: OS:

 

 [2016-03-09 00:24 UTC] iquito at gmx dot net
Description:
------------
With PHP7, it makes sense to enable opcache for CLI together with the opcache.file_cache options. I tried the following options:

opcache.enable=1
opcache.enable_cli=1
opcache.file_cache="/srv/php-file-cache"
opcache.file_cache_only=0
opcache.file_cache_consistency_checks=1

I found out that even though cron jobs worked fine, no files were cached. php CLI seems to completely ignore any opcache settings, and "phpinfo();" from command line also contains no opcache section. FPM correctly recognizes opcache settings and also displays them with phpinfo.

Test script:
---------------
Run php -d opcache.enable=1 inittest.php

inittest.php:

<?php
echo ini_get('opcache.enable');

----

Another way to easily test it, is to run "<?php phpinfo();" from command line - no opcache section is contained in the output, no matter the php.ini settings.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-09 00:38 UTC] iquito at gmx dot net
I actually just "solved" it myself - php.ini needs a line with "zend_extension=opcache.so" to enable opcache in CLI.

This is not the case with FPM - I compiled PHP myself, so including opcache.so seems not to be necessary for FPM. But it is necessary for CLI. Maybe this is a possible configuration improvement for the PHP CLI compilation process?
 [2016-03-09 00:51 UTC] iquito at gmx dot net
-Status: Open +Status: Closed
 [2016-03-09 00:51 UTC] iquito at gmx dot net
I guess I just overlooked the zend_extension part - seems to be fine now.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 17:03:35 2021 UTC