4

I installed NextCloud and in the summary window it keeps telling me that my OPCache is not enabled. I have enabled it and I am seeing conflicting information about if it really is enabled or not.

Ubuntu 18.04.1 | PHP 7.2.11-2

$ sudo cat /etc/php/7.2/apache2/php.ini | grep opcache
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
opcache.revalidate_freq=1
;opcache.revalidate_path=0
opcache.save_comments=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
;opcache.restrict_api=
;opcache.mmap_base=
;opcache.file_cache=
;opcache.file_cache_only=0
;opcache.file_cache_consistency_checks=1
; Implies opcache.file_cache_only=1 for a certain process that failed to
;opcache.file_cache_fallback=1
;opcache.huge_code_pages=1
;opcache.validate_permission=0
;opcache.validate_root=0
;opcache.opt_debug_level=0

Here is my output of php -i:

$ php -i
Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI

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 => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
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.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

Then finally, looking at a phpinfo() generated page, I see it loading the php.ini file from the correct one I have edited from the first block. The only additional .ini file it is loading is from the mods-available folder:

$ sudo cat /etc/php/7.2/mods-available/opcache.ini
; configuration for php opcache module
; priority=10
zend_extension=/usr/lib/php/20170718/opcache.so

There isn't any of the settings in that file, so the only file I see those settings in is the php.ini file, which is the same one being loaded from phpinfo(). These settings have been set for a while too, I am just now noticing they weren't taking affect. So the apache server has been rebooted with these settings saved. What am I missing here?

Edit: Here are some screenshots of the phpinfo() screen for further clarification: phpinfo() 1

phpinfo() 2

user2613018
  • 91
  • 1
  • 2
  • 7
  • Judging from the paths it looks like you might have more than one version of PHP installed side-by-side. You should double check that you're running the version you think, and that it is loading the config you think it should. – Sammitch Oct 15 '18 at 19:51
  • I have had different versions in the past. I have since upgraded to different ones and switched them over. Here is what version it is currently running: `$ php -v PHP 7.2.11-2+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 15 2018 11:40:35) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.11-2+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies` – user2613018 Oct 15 '18 at 20:03
  • Please run `php -a` and then run the following command to see what it says: `print_r(opcache_get_configuration());` If you find `opcache.enable` is true, then it's enabled. However, it's not enabled for cli. – Tuhin Oct 15 '18 at 19:33
  • It does show in that output that it is enabled. It's only the output of php -i where it shows it's disabled. – user2613018 Oct 15 '18 at 20:05
  • so if you would like to enable it for cli, then you'll probably need to find out the .ini file for php-cli, and update it there. – Tuhin May 27 '21 at 12:23

1 Answers1

0

Well after playing around for a few hours, I think I figured it out. In par with what @Sammitch said. When I was doing an apt-get update, it was installing 7.3 php files for some reason. So I purged those and verified my config for php was set to default to 7.2 and then did another update and autoremove. That seemed to clear that confusion up. Not sure how that happened though.

user2613018
  • 91
  • 1
  • 2
  • 7