php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71296 Opcache Fatal error when enabling opcache.file_cache_only
Submitted: 2016-01-06 23:04 UTC Modified: 2018-07-01 04:22 UTC
Votes:6
Avg. Score:3.5 ± 1.3
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (20.0%)
From: cyberdevil001 at telenet dot be Assigned: cmb (profile)
Status: No Feedback Package: opcache
PHP Version: 7.0.1 OS: CentOS
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: cyberdevil001 at telenet dot be
New email:
PHP Version: OS:

 

 [2016-01-06 23:04 UTC] cyberdevil001 at telenet dot be
Description:
------------
Configure Command =>  './configure'  '--prefix=/usr/local/php70' '--program-suffix=70' '--with-config-file-scan-dir=/usr/local/php70/lib/php.conf.d' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-libxml-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=mysqlnd' '--with-pcre-regex=/usr/local' '--with-pdo-mysql=mysqlnd' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-sockets' '--enable-soap' '--enable-mbstring' '--with-icu-dir=/usr/local/icu' '--enable-opcache' '--enable-opcache-file' '--enable-opcache-filecache' '--enable-intl'

PHP.INI settings:
opcache.memory_consumption=32
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=3000
opcache.revalidate_freq=60
opcache.fast_shutdown=0
opcache.enable_cli=1
opcache.file_cache_only=1
opcache.file_cache=/tmp/.opcache/

Test script:
---------------
/usr/local/bin/php --version
PHP 7.0.1 (cli) (built: Jan  5 2016 23:49:38) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


Opcache PHP info via CLI:

Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Disabled
File Cache => Enabled
Startup => OK

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 0 => 0
opcache.file_cache => /tmp/.opcache/ => /tmp/.opcache/
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 3000 => 3000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 32 => 32
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 60 => 60
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On



Expected result:
----------------
Opcache.file_cache_only should write files inside /tmp/.opcache and not show the error below because opcache.file_cache is actually set correct according to php-cli output. Error in logs is shown while running any script (for example: <?php phpinfo(); ?>)

Actual result:
--------------
tail -n 2 /var/log/httpd/error_log
Wed Jan  6 16:53:01 2016 (846663): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache
Wed Jan  6 16:53:03 2016 (846686): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-07 03:30 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2016-01-07 03:30 UTC] laruence@php.net
try -d opcache.log_verbosity_level=3, it probably because /tmp/.opcache is not accessable
 [2016-01-07 09:15 UTC] cyberdevil001 at telenet dot be
Changed the log_verbosity_level to 3 with the following result:

Thu Jan  7 10:11:34 2016 (26904): Warning opcache.file_cache must be a full path of accessable directory.
Thu Jan  7 10:11:34 2016 (26904): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache

Information of the directory:

ls -al /tmp/.opcache/
totaal 8
drwxrwxrwx   2 root root 4096  5 jan 23:36 .
drwxrwxrwt. 15 root root 4096  7 jan 10:11 ..

So directory has all the rights to be used.
Checked the PHP code https://github.com/php/php-src/blob/master/ext/opcache/ZendAccelerator.c :


#ifdef HAVE_OPCACHE_FILE_CACHE
	} else if (!ZCG(accel_directives).file_cache) {
		accel_startup_ok = 0;
		zend_accel_error(ACCEL_LOG_FATAL, "opcache.file_cache_only is set without a proper setting of opcache.file_cache");
		return SUCCESS;
	} 

So this error will only be shown if opcache.file_cache is empty right? Which is not the case.
 [2016-01-07 09:44 UTC] cyberdevil001 at telenet dot be
-Status: Feedback +Status: Open
 [2016-01-07 09:44 UTC] cyberdevil001 at telenet dot be
Was able to get it working by changing the path to:

opcache.file_cache=/home/admin/public_html/.opcache

Why is it not working with /tmp/.opcache while this folder is set in the open_basedir setting:
open_basedir	/home/admin/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php70/lib/php/

Changed the owner of /tmp/.opcache to admin which is the same as /home/admin/public_html/.opcache but still it doesn't work in the /tmp directory.
 [2016-12-21 13:44 UTC] sailormax at inbox dot lv
Same problem on Windows. PHP 7.0.14/7.1.0

display_errors = On
display_startup_errors = On
error_reporting = E_ALL
extension_dir = ".\ext"
zend_extension=php_opcache.dll
opcache.enable = 1
opcache.enable_cli = 1
opcache.huge_code_pages = 1
opcache.file_cache = ".\temp\opcache"
opcache.file_cache_only = 1
opcache.file_cache_consistency_checks = 1
opcache.file_cache_fallback = 1

php --version
=> (13140): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache
 [2017-04-04 14:51 UTC] max dot novikov at gmail dot com
I've experienced the same issue and found out that you cannot set absolute path for opcache directory, only relative, for reasons unknown. I.e.
/var/www/html/.opcache doesn't work
../html/.opcache does
 [2018-06-15 12:56 UTC] php at 9hz dot de
I know it's an old question, but:
>> Why is it not working with /tmp/.opcache while this folder is set in the open_basedir setting:
>> open_basedir	>> /home/admin/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php70/lib/php/

I think debian uses a virtual /tmp/ directory for each process. so if you create .opcache within you ssh's /tmp/ that directory does not exists in apache's /tmp dir.
try simply using /tmp/ then it should work
 [2018-06-15 13:00 UTC] spam2 at rhsoft dot net
in 2018 each service should have it's own /tmp and /var/tmp for obvious security reasons and so /tmp is pretty fine

https://www.freedesktop.org/software/systemd/man/systemd.exec.html

PrivateTmp=
Takes a boolean argument. If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace. This is useful to secure access to temporary files of the process, but makes sharing between processes via /tmp or /var/tmp impossible. If this is enabled, all temporary files created by a service in these directories will be removed after the service is stopped. Defaults to false. It is possible to run two or more units within the same private /tmp and /var/tmp namespace by using the JoinsNamespaceOf= directive, see systemd.unit(5) for details. This setting is implied if DynamicUser= is set. For this setting the same restrictions regarding mount propagation and privileges apply as for ReadOnlyPaths= and related calls, see above. Enabling this setting has the side effect of adding Requires= and After= dependencies on all mount units necessary to access /tmp and /var/tmp. Moreover an implicitly After= ordering on systemd-tmpfiles-setup.service(8) is added.
 [2018-06-18 17:54 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-06-18 17:54 UTC] cmb@php.net
> I think debian uses a virtual /tmp/ directory for each process.
> so if you create .opcache within you ssh's /tmp/ that directory
> does not exists in apache's /tmp dir.

Good catch!

> try simply using /tmp/ then it should work

Does it?
 [2018-07-01 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jul 06 07:01:27 2020 UTC