morrow95

Well-Known Member
Oct 8, 2006
163
8
168
Started using opcache with php 7.3 and mod_lsapi. Handler is set to lsapi in multiphp manager. I am NOT using php-fpm and using inherited php on all domains (7.3). I do not have domain specific php.ini files in place - all use the global.

I have looked on the forums and everything points to additional steps when using php-fpm, but I am not using that. There have been no lines added in the php.ini using multiphp ini editor in whm - I expected them to be there like any other module.

Where are these default settings being declared at and where is the correct place to edit them so those edits will not be removed on updates?
 

morrow95

Well-Known Member
Oct 8, 2006
163
8
168
To add to this. I would like to have account specific opcache settings. I just created a php.ini file for an account's /home/ folder with :

; disable opcache since I use this for development
opcache.enable = 0

This account is still actively using opcache and running though. Shouldn't this local php.ini override this particular setting and disable opcache for this entire account?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
You might check the following threads:

 

morrow95

Well-Known Member
Oct 8, 2006
163
8
168
Already saw and read those Lauren. I am not using php-fpm. I did find where to edit the setting (/opt/cpanel/ea-php73/root/etc/php.d/10-opcache.ini), but do not know if those will 'stay' if updates are made or not. Editing files directly with whm/cpanel 'usually' never keeps the settings after an update unless they are entered in a specific place/way. They don't answer my question about trying to disable opcache with an account specific php.ini either. Maybe that is not possible to do? I'm not sure - so I am asking.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
That .ini file is editable and we don't make any configuration changes to opcache nor should they be overwritten when you make them there. There are some instances where you can edit files - especially in the event they don't have their own UI.

One of the things I linked you to those threads for was the links within them but ultimately you can disable opcache per user in the .ini file - depending on the handler you're using you'd add the following in either the php.ini or .user.ini

Code:
opcache.enable=0
 

morrow95

Well-Known Member
Oct 8, 2006
163
8
168
Tried that already. I cleared the cache afterwards and it was still caching files on the account/domain I disabled it. I guess that means this won't work when using lsapi as the php handler (mod_lsapi to be specific)? Can you confirm that?

If so, I believe I can 'sort of' achieve the same affect by adding that account's home directory to the opcache blacklist, but wanted to see if I can just flat out disable it first. Thanks for any info.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
Hi @morrow95

I added it to a .user.ini yesterday and confirmed it works but for mod_lsapi i just tested added a php_flag in the .htaccess as follows and that was successful:

Code:
php_flag opcache.enable Off
For example I have the following in my .htaccess

Code:
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 32M
   php_value post_max_size 8M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 2M
   php_flag zlib.output_compression Off
   php_flag opcache.enable Off
</IfModule>
 

morrow95

Well-Known Member
Oct 8, 2006
163
8
168
Awesome - thank you Lauren! I didn't think to use htaccess for this. So I guess that means I can manipulate the opchache settings any way I want then for any accounts/folders/etc which is even better. I'll run some tests with this later today. Thanks!
 
  • Like
Reactions: cPanelLauren

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
Also good to note that if you're using CloudLinux's full version of mod_lsapi as opposed to our version you may be able to configure it to recognize .ini files using a Pre VirtualHost include MultiPHP INI Editor is not working with mod_lsapi

Let me know if the .htaccess solution works for you though!
 

morrow95

Well-Known Member
Oct 8, 2006
163
8
168
It seems to work fine. What is surprising to me is it seems like each account has its own opcache. If I look at the opcache stats they are different for each account (different memory usage, hit rate, keys, etc). I could see that becoming an issue if our server had a ton of accounts on it as it would use the default 128MB for each one after being enabled.
 
  • Like
Reactions: cPanelLauren

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
I'm glad to hear it's working out. The overhead of caching, in general, is something you definitely want to take into account. It makes things load faster but causing higher memory and resource consumption on the server in some cases, due of course to the cache.