Enabling OPcache for Nextcloud in CWPpro

Enabling OPcache for Nextcloud in CWPpro

Enabling OPcache for Nextcloud in CWPpro is pretty simple and should only take a few minutes.

In order to enable OPcache in CWP7 you need to add the path to opcache.so in your php.ini in addition to the settings Nextcloud specifies.

The path will look like this assuming you are using PHP 7.3 from PHP Selector V2 to select PHP 7.3.x for your PHP distribution (which also requires an additional edit to your Nextcloud .htaccess file.) The first line of your .htaccess should read:

AddHandler application/x-httpd-php73 .php

Your php.ini needs changed to load OPcache, but first you must find the path to the opcache.so extension. It should be located at: /opt/alt/php73/usr/lib/php/extensions/no-debug-non-zts-XXXXXXXX/opcache.so. The XXXXXXXX will be a number from the compiling of PHP 7.3. My full path with PHP 7.3.8 is: /opt/alt/php73/usr/lib/php/extensions/no-debug-non-zts-20180731/opcache.so.

Open your php.ini at /opt/alt/php72/usr/php/php.ini. Search for the OPcache section and enter the file path on a new line below [opcache] that points to opcache.so like so:

zend_extension ="/opt/alt/php73/usr/lib/php/extensions/no-debug-non-zts-20180731/opcache.so"

Then add the Nextcloud reccomended settings below it – they can be found at https://docs.nextcloud.com/server/16/admin_manual/installation/server_tuning.html#enable-php-opcache


It should look something like this:

opcache php settings

opcache settings for Nextcloud 16

That’s it. Just execute a restart of Apache.

systemctl restart httpd.service

Nextcloud should now be using OPcache and won’t complain in the “Overview” section of Nextcloud anymore.

Leave a Reply

Your email address will not be published. Required fields are marked *