PHP OPcache Issue on Centos 7 and php7

13 posts / 0 new
Last post
#1 Thu, 08/31/2017 - 13:20
Lordy

PHP OPcache Issue on Centos 7 and php7

So i have been trying to get Nextcloud working and getting around the OPCache warning.

The PHP OPcache is not properly configured. For better performance we recommend to use following settings in the php.ini:

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

i have tried to edit the virtual servers php.ini file . also the opcache.ini . without any luck.

when checking phpinfo.php file i can see opcache is on but opcache cli is off even too its sett to on or 1 in the ini file.

anyone got a clue how to fix this issue?

Thu, 08/31/2017 - 14:27
Joe
Joe's picture

What execution mode are you using?

--

Check out the forum guidelines!

Thu, 08/31/2017 - 14:38
Lordy

the default one i assume. this one :) " FCGId (run as virtual server owner) " i have not tried to change to much there.

Thu, 08/31/2017 - 15:51
Joe
Joe's picture

OK, so that should be using the domain user's php.ini, but keep in mind there may be multiple php.ini files (and the link from php.ini might point to the php5 file). Also, there are multiple system-wide php configuration files and locations (php7 is not in /etc, it's in /etc/opt/rh/rh-php7.0).

One thing I noticed is that because Virtualmin starts from the system php.ini (it copies it over when creating the new virtual server), it has an include directive, so it pulls in configuration from the system (things in /etc/php.d), so opcache would, by default, be pulled in from the system-wide opcache.ini. But, if you're using php7 you need to modify the php7 configuration files...not the ones in /etc/php.d. The php7 packages on CentOS have their configuration in /etc/opt/rh/rh-php70/php.d.

That said, when I modified /home/domain/etc/php7.0/php.ini I was able to include your example configuration above at the end of the file (after the include that pulls in the system-wide configs) and turn on opcache.enable_cli and it shows up in my phpinfo() page.

So, to be clear and concise:

Edit /home/domain/etc/php7.0/php.ini and add your options near the end of the file (I like to put changes before the "Local Variables" section).

Reload Apache (systemctl reload httpd).

Test. It should Just Work.

As an aside: Other modes use other files (mod_php uses the system-wide php.ini for whichever php version is enabled, php-fpm uses per-domain pool configuration files in /etc/php-fpm.d on CentOS, I don't know its exact path on Debian/Ubuntu).

--

Check out the forum guidelines!

Thu, 08/31/2017 - 16:43
Lordy

i just tried your suggestion on editing the /home/domain/etc/php7.0/php.ini " i ofc changed the domain with the right one ;) " and did systemctl reload httpd . but this warning error still exist.

EDIT: i did notice this in the apache error log file [Thu Aug 31 16:37:14.235004 2017] [authz_core:error] [pid 6779] [client 81...*:63513] AH01630: client denied by server configuration: /home/cloud/public_html/data/.ocdata

Thu, 08/31/2017 - 20:01
Joe
Joe's picture

Can you check with a file that just has phpinfo() in it? I'd like to know for sure that it's actually not enabling opcache cli. When I did that, it definitely changed configuration (and I'm testing on a recently installed CentOS 7 system).

--

Check out the forum guidelines!

Fri, 09/01/2017 - 09:04
Lordy

sure i can.

local : opcache.blacklist_filename /etc/opt/rh/rh-php70/php.d/opcache.blacklist | master: /etc/opt/rh/rh-php70/php.d/opcache.blacklist opcache.consistency_checks 0 | master: 0 opcache.dups_fix Off | master: Off opcache.enable On | master: On opcache.enable_cli On | master: On

So they it seems to be on.

Fri, 09/01/2017 - 11:46
Joe
Joe's picture

So, why is the app complaining? What's the exact error at this point?

--

Check out the forum guidelines!

Fri, 09/01/2017 - 13:26
Lordy

everything its complaining about is currently this

No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.
The PHP OPcache is not properly configured. For better performance we recommend to use following settings in the php.ini:

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

no errors in the logs other then the one above.

Fri, 09/01/2017 - 13:50
Lordy

i got opcache fixed.. :D

I went into /etc/opt/rh/rh-php70/php.d and edited 10-opcache.ini so it also had cli set to 1 . and that made the warning go away.

Fri, 09/01/2017 - 13:51
Lordy

Everything that was the issue here seems to have been fixed as described above :) . really appreciated the help

Fri, 09/01/2017 - 22:09
Joe
Joe's picture

So, that kinda hints that the app is running under mod_php rather the fcgid. Did you install it using the Virtualmin Install Script for it, or some other way?

--

Check out the forum guidelines!

Sat, 09/02/2017 - 06:24
Lordy

i installed it with the virtualmin install script since my friend is pro virtualmin user :) .

but if it is mod_php why is it saying fcgid under the php settings on the virtual machine ?

Topic locked