Bug #71296 [Com]: Opcache Fatal error when enabling opcache.file_cache_only

From: Date: Fri, 15 Jun 2018 13:00:47 +0000
Subject: Bug #71296 [Com]: Opcache Fatal error when enabling opcache.file_cache_only
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215739@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71296&edit=1

 ID:                 71296
 Comment by:         spam2 at rhsoft dot net
 Reported by:        cyberdevil001 at telenet dot be
 Summary:            Opcache Fatal error when enabling
                     opcache.file_cache_only
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   CentOS
 PHP Version:        7.0.1
 Block user comment: N
 Private report:     N

 New Comment:

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 /v!
 ar/tmp. Moreover an implicitly After= ordering on systemd-tmpfiles-setup.service(8) is added.


Previous Comments:
------------------------------------------------------------------------
[2018-06-15 12:56:06] 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

------------------------------------------------------------------------
[2017-04-04 14:51:43] 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

------------------------------------------------------------------------
[2016-12-21 13:44:07] 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

------------------------------------------------------------------------
[2016-01-07 09:44:25] 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-01-07 09:15:05] 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.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=71296


--
Edit this bug report at https://bugs.php.net/bug.php?id=71296&edit=1


Thread (10 messages)

« previous php.bugs (#215739) next »