Opcache settings ?

General discussions around KeyHelp.
Post Reply
amarc
Posts: 52
Joined: Thu 7. May 2020, 18:56

Opcache settings ?

Post by amarc »

Hello,

where can I adjust current opcache settings for PHP versions ? Where are 'defaults' located ? For example opcache.max_accelerated_files and opcache.memory_consumption ?

Is /opt/keyhelp/php/x.x/etc/conf.d/01-opcache.ini right way to adjust this ? What will happen to this file on updates ?


ty.
User avatar
Daniel
Keyweb AG
Posts: 150
Joined: Mon 25. Jan 2016, 04:42

Re: Opcache settings ?

Post by Daniel »

Hello,

you can just insert the opcache settings in the same submenu as like "disable_functions" for php.
Just edit at the "User Administration" the related user where you need to set opcache values and follow with "</> PHP".
Then scroll down to "Additional PHP directives" and insert opcache values.

I provide you a example:

Code: Select all

opcache.enable_cli=1
opcache.interned_strings_buffer=20
opcache.max_accelerated_files=3000
opcache.memory_consumption=64M
opcache.save_comments=1
opcache.revalidate_freq=1
opcache.validate_timestamps = 0
output_buffering = off
Mit freundlichen Grüßen / Best regards
Daniel Marckardt

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
https://www.keyweb.de - https://www.keyhelp.de
**************************************************************
amarc
Posts: 52
Joined: Thu 7. May 2020, 18:56

Re: Opcache settings ?

Post by amarc »

Thanks for a tip. To be honest I did not even know there is this fields. I guess I want it under

Code: Select all

Non-overwritable directives
in this case ?

ty.
User avatar
Alexander
Keyweb AG
Posts: 4825
Joined: Wed 20. Jan 2016, 02:23

Re: Opcache settings ?

Post by Alexander »

Depends on you use case but yes, you probably want it under "Non-overwritable directives".
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
amarc
Posts: 52
Joined: Thu 7. May 2020, 18:56

Re: Opcache settings ?

Post by amarc »

Forgot to give feedback this worked but also it seems some of options here are not respected under 26.0. Or could it be that this actually worked for me on previous version which was running Debian 13 and now I just installed 26.0 on Ubuntu 24.04. So it could be either 26.0 or Ubuntu issue.

I have this setting:

Code: Select all

opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10002
opcache.revalidate_freq=0        
opcache.validate_timestamps=0    
opcache.save_comments=1
opcache.jit_buffer_size=0M
opcache.jit=disable
And for example

Code: Select all

opcache.max_accelerated_files
value is visible under phpinfo but

Code: Select all

opcache.interned_strings_buffer
and

Code: Select all

opcache.memory_consumption
are not. No matter what I tried. Then I figured I will adjust these 2 in /opt/keyhelp/php/8.5/etc/php.ini (as I figured out it's pulling from there) and it actually reflected on user's website phpinfo. But this is now "global" I guess for all users running PHP8.5.


This is in users php-fpm.d/*.conf:

Code: Select all

; PHP immutable directives
php_admin_value[upload_tmp_dir] = /home/users/w4821/tmp/
php_admin_value[soap.wsdl_cache_dir] = /home/users/w4821/tmp/
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i
php_admin_value[memory_limit] = 256M
php_admin_value[max_execution_time] = 120
php_admin_value[post_max_size] = 72M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[open_basedir] = /home/users/w4821/www:/home/users/w4821/files:/home/users/w4821/tmp
php_admin_value[disable_functions] = apache_child_terminate, apache_note, apache_setenv, curl_multi_exec, define_syslog_variables, dl, exec, link, openlog, passthru, pcntl_exec, pcntl_fork, pcntl_setpriority, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid>
php_admin_value[opcache.memory_consumption] = 256
php_admin_value[opcache.interned_strings_buffer] = 16
php_admin_value[opcache.max_accelerated_files] = 10002
php_admin_value[opcache.revalidate_freq] = 0
php_admin_value[opcache.validate_timestamps] = 0
php_admin_value[opcache.save_comments] = 1
php_admin_value[opcache.jit_buffer_size] = 0M
php_admin_value[opcache.jit] = disable

Any ideas what could it be ?
User avatar
Alexander
Keyweb AG
Posts: 4825
Joined: Wed 20. Jan 2016, 02:23

Re: Opcache settings ?

Post by Alexander »

I have checked it and cannot reproduce it.

I could change all values with the "Non-overwritable directives" input field and they showed up accordingly with phpinfo().
This worked for all values you mentioned, beside "opcache.jit", which might only work when starting PHP-FPM.

Be aware that there is an up to 1 minute delay, between clicking "Save" and the values being updated.
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
amarc
Posts: 52
Joined: Thu 7. May 2020, 18:56

Re: Opcache settings ?

Post by amarc »

Thanks, but still does not work for me. I commented (default) back things in /opt/keyhelp/php/8.5/etc/php.ini , did "save" once again and memory_consumption is back to 128 even tho I have it 256. Same for interned_strings_buffer.

I would love to cache log(s) what could fail here if you tell me where to look at.. Or I can even provide "Support" access if you have time.
User avatar
Alexander
Keyweb AG
Posts: 4825
Joined: Wed 20. Jan 2016, 02:23

Re: Opcache settings ?

Post by Alexander »

Or I can even provide "Support" access if you have time.
Enable Support access under "Configuration" and i will have a look. You need to send me the server IP and SSH-Port via private message.
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
Post Reply