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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 19:01:27 2024 UTC