Skip to content

PhP warning - Cannot load Zend OPcache - it was already loaded #416

Closed

Description

@Iolaum

PROBLEMS

I am not sure if this is a problem with ncp, php/raspbian or not a problem at all. Simply running php -v gives an error:

$ php -v
Cannot load Zend OPcache - it was already loaded
PHP 7.0.27-0+deb9u1 (cli) (built: Jan  5 2018 13:51:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.27-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies

Looking into some other log files as well, the error gets thrown at sys log every 30 min:

root@nextcloudpi:/var/log# cat syslog | grep OPcache
Feb 15 06:39:09 nextcloudpi sessionclean[10872]: Cannot load Zend OPcache - it was already loaded
Feb 15 06:39:09 nextcloudpi sessionclean[10872]: Cannot load Zend OPcache - it was already loaded
Feb 15 07:09:09 nextcloudpi sessionclean[11044]: Cannot load Zend OPcache - it was already loaded
Feb 15 07:09:09 nextcloudpi sessionclean[11044]: Cannot load Zend OPcache - it was already loaded
Feb 15 07:39:09 nextcloudpi sessionclean[11204]: Cannot load Zend OPcache - it was already loaded
Feb 15 07:39:10 nextcloudpi sessionclean[11204]: Cannot load Zend OPcache - it was already loaded
Feb 15 08:09:09 nextcloudpi sessionclean[11315]: Cannot load Zend OPcache - it was already loaded
...

Paste the output of sudo ncp-report:

NextCloudPi diagnostics

Cannot load Zend OPcache - it was already loaded
NextCloudPi version  v0.46.10
NextCloudPi image    NextCloudPi_12-04-17
distribution         Raspbian GNU/Linux 9 \n \l
automount            yes
USB devices          sda 
datadir              /media/USBdrive/ncdata
data in SD           no
data filesystem      ext2/ext3
data disk usage      182G/917G
rootfs usage         1.7G/3.6G
swapfile             /media/wd1/swap
Nextcloud check      ok
Nextcloud version    12.0.4.3
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
Postfix service      up
internet check       ok
port check 80        open
port check 443       open
IP                   192.168.1.20
gateway              192.168.1.1
interface            eth0
certificates         $HOSTNAME
certs due            25 days
NAT loopback         no
uptime               2days

Nextcloud configuration

Cannot load Zend OPcache - it was already loaded
{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": {
            "0": "$HOSTNAME:443",
            "1": "192.168.1.20",
            "4": "$HOSTNAME",
            "2": "$HOSTNAME"
        },
        "datadirectory": "\/media\/USBdrive\/ncdata",
        "overwrite.cli.url": "https:\/\/$HOSTNAME",
        "dbtype": "mysql",
        "version": "12.0.4.3",
        "dbname": "nextcloud",
        "dbhost": "localhost",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "ocs86rkb5syt",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "\/var\/run\/redis\/redis.sock",
            "port": 0,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "mail_smtpmode": "php",
        "mail_smtpauthtype": "LOGIN",
        "mail_from_address": "admin",
        "mail_domain": "$HOSTNAME",
        "overwriteprotocol": "https",
        "maintenance": false,
        "loglevel": "2",
        "logfile": "\/media\/wd1\/ncdata\/nextcloud.log",
        "log_type": "file"
    }
}

HTTPd logs

[Thu Feb 15 06:25:05.002191 2018] [mpm_event:notice] [pid 859:tid 1992183808] AH00489: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l   configured -- resuming normal operations
[Thu Feb 15 06:25:05.002289 2018] [core:notice] [pid 859:tid 1992183808] AH00094: Command line: '/usr/sbin/apache2'

Database logs

tail: cannot open '/var/log/mysql/*.log' for reading: No such file or directory

Nextcloud logs

{"reqId":"WoCkVX8AAQEAAAG4u6UAAA4B","level":2,"time":"2018-02-11T20:15:18+00:00","remoteAddr":"137.226.113.20","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"137.226.113.20\" tried to access using \"79.75.141.71\" as host.","userAgent":"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko\/20100101 Firefox\/50.0","version":"12.0.4.3"}
{"reqId":"WoCkVn8AAQEAAAG4u60AAA4J","level":2,"time":"2018-02-11T20:15:19+00:00","remoteAddr":"137.226.113.20","user":"--","app":"core","method":"GET","url":"\/index.php\/js\/core\/merged-template-prepend.js?v=2793255a2c31f4b4c2eab906af15ce25-1","message":"Trusted domain error. \"137.226.113.20\" tried to access using \"79.75.141.71\" as host.","userAgent":"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko\/20100101 Firefox\/50.0","version":"12.0.4.3"}
{"reqId":"WoDQD38AAQEAAAHFrL4AAABS","level":2,"time":"2018-02-11T23:21:51+00:00","remoteAddr":"107.170.227.152","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"107.170.227.152\" tried to access using \"79.75.141.71\" as host.","userAgent":"Mozilla\/5.0 zgrab\/0.x","version":"12.0.4.3"}
{"reqId":"WoF0O38AAQEAAB-8900AAAAA","level":3,"time":"2018-02-12T11:02:19+00:00","remoteAddr":"210.16.189.29","user":"--","app":"PHP","method":"GET","url":"\/admin\/config.php","message":"Exception: The requested uri(\/admin\/config.php) cannot be processed by the script '\/core\/templates\/404.php') at \/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php#729","userAgent":"curl\/7.19.7 (i386-redhat-linux-gnu) libcurl\/7.19.7 NSS\/3.27.1 zlib\/1.2.3 libidn\/1.18 libssh2\/1.4.2","version":"12.0.4.3"}
{"reqId":"WoHJ6H8AAQEAAB-893IAAAAO","level":2,"time":"2018-02-12T17:07:53+00:00","remoteAddr":"164.52.6.150","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"164.52.6.150\" tried to access using \"79.75.151.21:443\" as host.","userAgent":"Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko\/20100101 Firefox\/52.0","version":"12.0.4.3"}
{"reqId":"WoHjsn8AAQEAAB-8948AAAAS","level":2,"time":"2018-02-12T18:57:55+00:00","remoteAddr":"209.126.136.7","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"209.126.136.7\" tried to access using \"79.75.151.21\" as host.","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/57.0.2987.133 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoH69X8AAQEAACAK1dIAAABE","level":2,"time":"2018-02-12T20:37:09+00:00","remoteAddr":"139.162.78.135","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"139.162.78.135\" tried to access using \"79.75.151.21\" as host.","userAgent":"Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/45.0.2454.101 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoJC9H8AAQEAACAK9L8AAABL","level":2,"time":"2018-02-13T01:44:20+00:00","remoteAddr":"34.214.38.179","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"34.214.38.179\" tried to access using \"92.4.153.185:443\" as host.","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/50.0.2661.102 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoLhKn8AAQEAAD5A4SIAAABL","level":2,"time":"2018-02-13T12:59:22+00:00","remoteAddr":"139.162.78.135","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"139.162.78.135\" tried to access using \"92.4.153.185\" as host.","userAgent":"Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/45.0.2454.101 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoLrIn8AAQEAAD4wuFkAAAAH","level":2,"time":"2018-02-13T13:41:54+00:00","remoteAddr":"184.105.139.69","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"184.105.139.69\" tried to access using \"92.4.153.185\" as host.","userAgent":"--","version":"12.0.4.3"}
{"reqId":"WoMy238AAQEAAD4wxZkAAAAS","level":2,"time":"2018-02-13T18:47:55+00:00","remoteAddr":"107.170.227.37","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"107.170.227.37\" tried to access using \"79.75.128.116\" as host.","userAgent":"Mozilla\/5.0 zgrab\/0.x","version":"12.0.4.3"}
{"reqId":"WoOZQX8AAQEAAANxI7kAAAAT","level":2,"time":"2018-02-14T02:04:49+00:00","remoteAddr":"89.248.160.199","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"89.248.160.199\" tried to access using \"79.75.128.116\" as host.","userAgent":"libwww-perl\/6.31","version":"12.0.4.3"}
{"reqId":"WoQxAn8AAQEAAA2rWeEAAABQ","level":2,"time":"2018-02-14T12:52:19+00:00","remoteAddr":"184.105.139.69","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"184.105.139.69\" tried to access using \"79.75.128.116\" as host.","userAgent":"--","version":"12.0.4.3"}
{"reqId":"WoR7bH8AAQEAAA2rWg8AAABV","level":2,"time":"2018-02-14T18:09:48+00:00","remoteAddr":"60.191.38.77","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"60.191.38.77\" tried to access using \"79.75.128.116:443\" as host.","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko\/20100101 Firefox\/47.0","version":"12.0.4.3"}
{"reqId":"WoSXW38AAQEAAA2rWicAAABE","level":3,"time":"2018-02-14T20:08:59+00:00","remoteAddr":"163.172.192.121","user":"--","app":"PHP","method":"GET","url":"\/a2billing\/common\/javascript\/misc.js","message":"Exception: The requested uri(\/a2billing\/common\/javascript\/misc.js) cannot be processed by the script '\/core\/templates\/404.php') at \/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php#729","userAgent":"python-requests\/2.18.4","version":"12.0.4.3"}
{"reqId":"WoT5@38AAQEAAA2rWzoAAABJ","level":2,"time":"2018-02-15T03:09:47+00:00","remoteAddr":"139.162.78.135","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"139.162.78.135\" tried to access using \"79.75.128.116\" as host.","userAgent":"Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/45.0.2454.101 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoUEsX8AAQEAAA2rWzwAAABM","level":3,"time":"2018-02-15T03:55:29+00:00","remoteAddr":"163.172.192.121","user":"--","app":"PHP","method":"GET","url":"\/a2billing\/common\/javascript\/misc.js","message":"Exception: The requested uri(\/a2billing\/common\/javascript\/misc.js) cannot be processed by the script '\/core\/templates\/404.php') at \/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php#729","userAgent":"python-requests\/2.18.4","version":"12.0.4.3"}
{"reqId":"WoUVEH8AAQEAAA2i0dsAAAAL","level":2,"time":"2018-02-15T05:05:20+00:00","remoteAddr":"80.82.77.139","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"80.82.77.139\" tried to access using \"79.75.128.116\" as host.","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/34.0.1847.137 Safari\/537.36","version":"12.0.4.3"}
{"reqId":"WoV-C38AAQEAACmpy1YAAAAU","level":2,"time":"2018-02-15T12:37:31+00:00","remoteAddr":"216.218.206.66","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"216.218.206.66\" tried to access using \"79.75.156.41\" as host.","userAgent":"--","version":"12.0.4.3"}
{"reqId":"WoX18X8AAQEAACmpzJsAAAAH","level":2,"time":"2018-02-15T21:04:50+00:00","remoteAddr":"60.191.38.77","user":"--","app":"core","method":"GET","url":"\/","message":"Trusted domain error. \"60.191.38.77\" tried to access using \"79.75.156.41:443\" as host.","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko\/20100101 Firefox\/47.0","version":"12.0.4.3"}

Activity

  1. nachoparker commented on Feb 16, 2018

    @nachoparker
    Member

    (edited, wrong tab)

  2. nachoparker commented on Feb 16, 2018

    @nachoparker
    Member

    I think I found it. Some update duplicated the symlink for the opcache configuration

    # ls -l /etc/php/7.0/fpm/conf.d/ | grep opc
    lrwxrwxrwx 1 root root 39 Dec  4 13:29 10-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Feb  7 10:47 20-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini
    

    Can you replicate this finding?

    It is just a harmless warning.

  3. changed the title [-]PhP error ?[/-] [+]PhP warning - Cannot load Zend OPcache - it was already loaded[/+] on Feb 16, 2018
  4. Iolaum commented on Feb 16, 2018

    @Iolaum
    ContributorAuthor

    Yes I can replicate that:

    $ pwd
    /etc/php/7.0/fpm/conf.d
    $ ll | grep opcache
    lrwxrwxrwx 1 root root   39 Dec  4 13:29 10-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini
    lrwxrwxrwx 1 root root   39 Jan 14 22:49 20-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini
    

    Is the solution to just delete the second symlink?

  5. nachoparker commented on Feb 16, 2018

    @nachoparker
    Member

    yes, I fixed it in the update, please reopen if it still happens after v0.46.16

    thanks!

  6. self-assigned this
    on Feb 16, 2018
  7. Iolaum commented on Oct 27, 2018

    @Iolaum
    ContributorAuthor

    It looks like this bug reappeared as we moved to php7.2:

    $ echo "$( ls -l /etc/php/7.2/fpm/conf.d/*-opcache.ini |  wc -l )"
    2
    $ echo "$( ls -l /etc/php/7.2/cli/conf.d/*-opcache.ini |  wc -l )"
    2
    
    
  8. ovpc commented on Oct 27, 2018

    @ovpc
    Collaborator

    Strange, it only happens on my rpi3B+ , not on my Debian9 install

  9. Iolaum commented on Oct 27, 2018

    @Iolaum
    ContributorAuthor

    I think this bug creeped in after @nachoparker enabled the buster sources, not php7.2 but I am not 100% sure

  10. nachoparker commented on Oct 27, 2018

    @nachoparker
    Member

    probably with the jump to PHP7.2. Thanks for the PR!

  11. ovpc commented on Nov 17, 2018

    @ovpc
    Collaborator

    Back again ;-( 2 simlinks in /etc/php/7.2/cli/conf.d/ (10- and 20-) both pointing to /etc/php/7.2/mods-available/opcache.ini

  12. eogut commented on Nov 23, 2018

    @eogut

    Back again ;-( 2 simlinks in /etc/php/7.2/cli/conf.d/ (10- and 20-) both pointing to /etc/php/7.2/mods-available/opcache.ini

    I have that error, too!

  13. nachoparker commented on Nov 23, 2018

    @nachoparker
    Member

    should be fixed now again. Note that this is a harmless warning, that appears with updates. Not much we can do about it.

  14. 17 remaining items

  15. Knubbel commented on Feb 9, 2023

    @Knubbel

    Seems to have reappeared (Version is 1.51.0): lrwxrwxrwx 1 root root 39 Jan 22 02:31 10-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Feb 6 11:46 20-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini

    I just had an update to php.

    Yes, same with me.

    Update to PHP 8.1 seems to have generated new entries again.

    It does seem an regular recurring issue as that happened a week ago already with an update. Ev ery single PHP update recreates the lines.

    So I did

    sudo rm /etc/php/8.1/cli/conf.d/20-opcache.ini
    sudo rm /etc/php/8.1/fpm/conf.d/20-opcache.ini
    

    NCP Panel reports everything is up and running, but so far I could not reach the NC login screen.

    And then

    sudo service php8.1-fpm restart
    sudo systemctl restart apache2
    

    That worked.

  16. token0 commented on Jul 25, 2023

    @token0

    Manual fix.
    Find all occurrences:

    # for f in $(find /etc/php/ 2>/dev/null -name "*opc*") ; do ls -laFh $f;done
    lrwxrwxrwx 1 root root 39 Dec 29  2022 /etc/php/7.3/cli/conf.d/20-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jul  6  2020 /etc/php/7.3/cli/conf.d/10-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Dec 29  2022 /etc/php/7.3/cgi/conf.d/20-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jul  6  2020 /etc/php/7.3/cgi/conf.d/10-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Dec 29  2022 /etc/php/7.3/fpm/conf.d/20-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
    

    And then remove oldest duplicates. In my case those that was dated 2020.

    rm /etc/php/7.3/cli/conf.d/10-opcache.ini
    rm /etc/php/7.3/cgi/conf.d/10-opcache.ini
    
  17. torstenzenk commented on Nov 8, 2023

    @torstenzenk

    Or if

    for f in $(find /etc/php/ 2>/dev/null -name "opc") ; do ls -laFh $f;done

    shows you a list like this:

    lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/fpm/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini -rw-r--r-- 1 root root 95 Jun 9 21:37 /etc/php/8.2/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/embed/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/phpdbg/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/cli/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/cgi/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini lrwxrwxrwx 1 root root 39 Nov 2 15:31 /etc/php/8.2/apache2/conf.d/10-opcache.ini -> /etc/php/8.2/mods-available/opcache.ini`

    rename the opcache.ini from Apache
    Server:/etc/apache2/sites-available$ sudo mv /etc/php/8.2/apache2/conf.d/10-opcache.ini /etc/php/8.2/apache2/conf.d/10-opcache.original

    and restart Apache

    `

  18. miri64 commented on Jun 10, 2024

    @miri64

    This showed up again after updating the PHP packages to 8.1.29-1+020240606.65+debian121.gbp2ddf4e last Saturday (2024-06-08). I am on NCP v1.52.2:

    $ ls -l /etc/php/8.1/*/conf.d/*opcache*.ini
    lrwxrwxrwx 1 root root 39 May  2 03:15 /etc/php/8.1/cli/conf.d/10-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jun  8 20:44 /etc/php/8.1/cli/conf.d/20-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 May  2 03:15 /etc/php/8.1/fpm/conf.d/10-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jun  8 20:44 /etc/php/8.1/fpm/conf.d/20-opcache.ini -> /etc/php/8.1/mods-available/opcache.ini

    The usual workaround fixed it again:

    $ sudo rm /etc/php/8.1/*/conf.d/20-opcache.ini
  19. Matthionine commented on Jul 31, 2026

    @Matthionine

    This appears again with the update to php 8.3 and is resolved as before on ncp 1.58:

    $ ls -l /etc/php/8.*/*/conf.d/*opcache*.ini
    lrwxrwxrwx 1 root root 39 Sep 10  2024 /etc/php/8.3/cli/conf.d/10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jul 17 04:33 /etc/php/8.3/cli/conf.d/20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Sep 10  2024 /etc/php/8.3/fpm/conf.d/10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Jul 17 04:33 /etc/php/8.3/fpm/conf.d/20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    

    and can be fixed by deleting the additional .ini-file:

    $ sudo rm /etc/php/8.1/*/conf.d/20-opcache.ini
    
  20. janvlug commented on Oct 17, 2026

    @janvlug
    Contributor

    I saw the "Cannot load Zend OPcache - it was already loaded" already for a long time, but only today took action to investigate.

    I have:

    $ ls -l /etc/php/*/*/conf.d/ | grep opc
    lrwxrwxrwx 1 root root 39 Sep  8  2024 10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root 39 Aug 24 13:10 20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root  39 Sep  8  2024 10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    lrwxrwxrwx 1 root root  39 Aug 24 13:10 20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    

    Note that the 20-opcache.ini is the newest. I would expect it is best to remove the oldest link. But in the comments above some people remove the newest link. What is recommended?

    Should this issue be reopened?

  21. Knubbel commented on Oct 17, 2026

    @Knubbel
         Should this issue be reopened?
    

    I guess so. I let DeepSeek do an analysis on my installation and here is the summary of findings and advice:

    System Raspberry Pi 4B, NextcloudPi (NCP v1.58.0)
    OS Armbian 26.8.3, Debian 13 "trixie"
    PHP 8.3 from deb.sury.org (8.3.x-1+0~<date>...+debian13~1)
    Web server Apache 2.4.68 with php8.3-fpm
    Observed on every php8.3-* package upgrade since the NCP install (2024-09-24)
    Status root cause identified, fixed locally and in the NCP template, fix verified

    TL;DR

    NCP writes /etc/php/8.3/mods-available/opcache.ini without the ; priority=10 header line
    that the original sury template contains. php-helper falls back to priority 20 when the
    header is missing, so the php8.3-opcache postinst creates an additional 20-opcache.ini
    symlink next to the existing 10-opcache.ini on the next package update. Both symlinks resolve
    to the same file and both contain zend_extension=opcache.so → PHP loads OPcache twice and
    prints the warning.

    Permanent fix: add ; priority=10 as the first line of
    /etc/php/8.3/mods-available/opcache.ini (and to the NCP template
    /usr/local/etc/ncp-templates/php/opcache.ini.sh). After that, phpenmod updates the existing
    10-priority symlink instead of creating a 20-priority duplicate.

    The warning itself is harmless (no performance loss, OPcache stays active) — it is log noise
    plus recurring manual cleanup after each PHP update.


    1. Symptom

    PHP prints a startup warning whenever a SAPI initialises:

    PHP Warning:  Cannot load Zend OPcache - it was already loaded in Unknown on line 0
    

    Where it shows up:

    • php -v output (CLI), e.g. when cron or monitoring scripts invoke PHP
    • journalctl -u php8.3-fpm (at every FPM start / reload)
    • syslog — on this box roughly every 30 minutes (periodic CLI invocations)
    • Nextcloud admin log is not affected by this warning

    The duplicate symlinks are visible directly:

    ls -l /etc/php/8.3/*/conf.d/*opcache*
    /etc/php/8.3/cli/conf.d/10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    /etc/php/8.3/cli/conf.d/20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    /etc/php/8.3/fpm/conf.d/10-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    /etc/php/8.3/fpm/conf.d/20-opcache.ini -> /etc/php/8.3/mods-available/opcache.ini
    

    Impact assessment:

    • No functional impact. OPcache is loaded (once), php -v still reports
      with Zend OPcache v8.3.x.
    • Log noise, both in journal and syslog, forever.
    • Recurring maintenance: after every PHP package update the duplicate is back and has to be
      removed manually (sudo rm …/20-opcache.ini) — unless the actual cause is fixed.

    2. Environment details

    Raspberry Pi 4 Model B
    Armbian 26.8.3 / Debian 13 (trixie)
    NextcloudPi v1.58.0 (installed 2024-09-24)
    PHP 8.3 (deb.sury.org), observed 8.3.32 -> 8.3.35
    Apache 2.4.68, MariaDB 11.8.6, Redis 8.0.2
    php8.3-fpm: 1 master + 24 workers (NCP PHPTHREADS=24)
    

    The box runs unattended NCP and Nextcloud updates daily (nc-autoupdate-ncp,
    nc-autoupdate-nc), Debian/Armbian security updates via unattended-upgrades, while sury PHP
    packages are only installed manually.


    3. Root cause (verified chain)

    1. NCP template /usr/local/etc/ncp-templates/php/opcache.ini.sh
       writes /etc/php/8.3/mods-available/opcache.ini
       WITHOUT the first line "; priority=10"
       (the sury original /usr/share/php8.3-opcache/opcache/opcache.ini has it)
    
    2. get_priority() in /usr/lib/php/php-helper parses exactly that header line.
       If it is missing, priority defaults to 20.
    
    3. /var/lib/dpkg/info/php8.3-opcache.postinst calls
       php_invoke enmod 8.3 ALL opcache
       on every update of the package, creating a NEW symlink with priority 20
       next to the already existing 10-opcache.ini.
    
    4. Both symlinks point to the same mods-available/opcache.ini,
       which contains zend_extension=opcache.so.
    
    5. PHP initialises the extension twice:
       "Cannot load Zend OPcache - it was already loaded"
    

    Original content that triggers the default:

    ; priority=10        <-- missing in NCP-generated file
    zend_extension=opcache.so

    Historical context on this system:

    Date Event
    2024-09-24 NCP installation creates the 10-opcache.ini symlinks (cli + fpm)
    2025-10-19 NCP template run rewrites mods-available/opcache.ini without the priority header
    since then every php8.3-opcache upgrade adds a 20-opcache.ini; manual rm after each update
    2026-10-01 cause investigated, permanent fix applied, verified with 8.3.32 → 8.3.35

    Note: the two symlinks are identical targets, so no configuration is lost or changed by
    removing either of them. The duplicate link is purely a naming/priority artefact.


    4. Who is affected / how to check

    Any NextcloudPi (or any system using Debian's php-helper) where
    mods-available/opcache.ini was rewritten by a template without the priority header.

    PHPV=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
    
    # 1. Is the header present? (no output = missing)
    grep -n '^; priority=' "/etc/php/$PHPV/mods-available/opcache.ini"
    
    # 2. How many opcache symlinks exist per SAPI?
    ls -l /etc/php/"$PHPV"/*/conf.d/*opcache*
    
    # 3. Actual warning?
    php -v 2>&1 | grep -i 'already loaded'

    Expected healthy state: exactly one 10-opcache.ini per SAPI, header present, no warning.


    5. Workarounds and fix

    5.1 Immediate cleanup (what we did after every update so far)

    sudo rm -f /etc/php/8.3/*/conf.d/20-opcache.ini
    sudo systemctl restart php8.3-fpm apache2

    This removes the warning until the next PHP package update — not a permanent fix.

    5.2 Permanent fix – local file (takes effect immediately)

    # check current state
    head -3 /etc/php/8.3/mods-available/opcache.ini
    
    # prepend the header (only if not already present)
    grep -q '^; priority=10' /etc/php/8.3/mods-available/opcache.ini || \
      sudo sed -i '1s/^/; priority=10\n/' /etc/php/8.3/mods-available/opcache.ini
    
    # verify
    head -3 /etc/php/8.3/mods-available/opcache.ini

    Result: phpenmod / php_invoke enmod now derive priority 10, so the existing
    10-opcache.ini symlink is updated in place and no 20-opcache.ini is created anymore.

    5.3 Permanent fix – NCP template (survives template re-runs)

    /usr/local/etc/ncp-templates/php/opcache.ini.sh writes the file during NCP operations
    (Nextcloud update, ncp-restore, data directory change). Add the same header there, as the
    first line emitted by the heredoc, directly before zend_extension=opcache.so:

    sudo cp /usr/local/etc/ncp-templates/php/opcache.ini.sh \
            /usr/local/etc/ncp-templates/php/opcache.ini.sh.bak-$(date +%Y%m%d)
    sudo nano /usr/local/etc/ncp-templates/php/opcache.ini.sh
    # inside the "cat <<EOF" block, insert as first line:
    ; priority=10

    Then verify:

    grep -n 'priority' /usr/local/etc/ncp-templates/php/opcache.ini.sh

    Caveat: an NCP self-update may overwrite the template again. Re-check the file after NCP
    updates (a simple grep is enough). The local file fix (5.2) remains active regardless.

    5.4 Important when dpkg/UCF asks about opcache.ini

    On a PHP update, if dpkg or UCF presents a conffile prompt for opcache.ini:
    keep the local version. Taking the package template drops NCP-specific settings such as
    opcache.file_cache pointing to the Nextcloud data directory. Re-check step 5.2 afterwards.

    5.5 Optional: reproduce the root cause on a disposable system

    sudo dpkg-reconfigure php8.3-opcache    # re-runs the postinst
    ls -l /etc/php/8.3/*/conf.d/*opcache*

    With the header missing, 20-opcache.ini reappears immediately.


    6. Verification after the fix (live, 2026-10-01)

    Sequence performed: set the header in mods-available/opcache.ini and in the NCP template
    (backups as .bak-20261001), then upgrade 17 × php8.3-* from 8.3.32 to 8.3.35 plus libgd3.

    Check Command Result
    Symlinks ls -la /etc/php/8.3/*/conf.d/*opcache* no 20-opcache.ini, only 10-opcache.ini per SAPI
    CLI php -v 8.3.35, no "already loaded"
    FPM log journalctl -u php8.3-fpm -n 30 --no-pager no warnings/errors
    Syslog grep -c 'already loaded' /var/log/syslog no new entries
    Services systemctl is-active apache2 mariadb redis-server php8.3-fpm AdGuardHome kopia-server all active
    Workers pgrep -c php8.3-fpm 25 (1 master + 24 workers)
    Nextcloud curl -sk https://localhost/status.php HTTP 200, "installed":true, ~80 ms
    User test file upload in browser + sync from mobile app passed, no new errors in NC log
    Reboot — not required for a pure PHP update

    No configuration prompts appeared during the upgrade; the fix has held since.
    The same pre-emptive fix was also applied to a second NCP box before its distribution upgrade
    (NCP v1.57.1 → v1.58.0, Debian 12 → 13); no duplicate symlink occurred there either.


    7. Suggested upstream change

    The bug is not in Debian's php-helper (defaulting to 20 for a missing header is documented
    behaviour) and not in the sury package (its original template contains the header). The
    divergence is in the NCP template:

    ncp-templates/php/opcache.ini.sh should emit ; priority=10 as its first line, matching
    the sury template. That is a one-line change and fixes the issue for every NCP installation
    using sury PHP, regardless of PHP version.

    Optional hardening: after a PHP update, NCP could check for duplicate *opcache* symlinks in
    conf.d and remove stale ones — but with the header in place this should never be necessary.

  22. ph818 commented on Oct 27, 2026

    @ph818

    This bug appeared for me after running ncp-dist-upgrade from bookwork to trixie. I noticed the problem because of all the new root mail. Thank you for the fixes -- I am implementing them on my system.

    @Knubbel

    5.3 Permanent fix – NCP template (survives template re-runs)

    /usr/local/etc/ncp-templates/php/opcache.ini.sh writes the file during NCP operations (Nextcloud update, ncp-restore, data directory change). Add the same header there, as the first line emitted by the heredoc, directly before zend_extension=opcache.so:

    sudo cp /usr/local/etc/ncp-templates/php/opcache.ini.sh
    /usr/local/etc/ncp-templates/php/opcache.ini.sh.bak-$(date +%Y%m%d)
    sudo nano /usr/local/etc/ncp-templates/php/opcache.ini.sh

    inside the "cat <<EOF" block, insert as first line:

    ; priority=10

    Then verify:

    grep -n 'priority' /usr/local/etc/ncp-templates/php/opcache.ini.sh

    I would like to verify, the text to insert into /usr/local/etc/ncp-templates/php/opcache.ini.sh is

    # ; priority=10
    

    with the # commenting it out, and not

    ; priority=10
    

    without the comment?

    Thank you :)

  23. FadeFx commented on Nov 19, 2026

    @FadeFx

    Yesterday I had an update to the mail app, I installed it and apache stopped. The reason was the 20-opcache.ini was placed in the PHP 8.5 fpm config, which caused PHP to refuse from starting, as opcache is not a module anymore in PHP 8.5. I had to delete the file to get apache and nextcloud to work again

  24. FadeFx commented on Nov 19, 2026

    @FadeFx

    Followup

    error.log is full of:

    AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.5-fpm.sock (localhost:8000) failed
    AH01079: failed to make connection to backend: localhost

    php8.5-fpm was dead (status=254). The journal shows this on every start attempt:

    PHP Warning: Failed loading Zend extension 'opcache.so' (tried: /usr/lib/php/20250925/opcache.so (...: cannot open shared object file: No such file or directory), ...)
    Fatal Error opcache.file_cache must be a full path of an accessible directory

    until systemd gives up with "Start request repeated too quickly".

    My /etc/php/8.5/mods-available/opcache.ini (written by NCP) starts with zend_extension=opcache.so and also has opcache.fast_shutdown=1 and opcache.file_cache=/media/myCloudDrive/ncdata/data/.opcache. There was a 20-opcache.ini in /etc/php/8.5/fpm/conf.d/ pointing to it.

    OPcache is built into PHP 8.5, so there is no opcache.so anymore (dpkg -S finds no package owning the ini, and no opcache package is installed).

    Deleting /etc/php/8.5/fpm/conf.d/20-opcache.ini, then
    systemctl reset-failed php8.5-fpm
    and
    systemctl start php8.5-fpm
    fixed it.

    I grepped /usr/local: ncp-update-nc.d/upgrade-php-trixie-8.5.sh runs phpenmod -v "${PHPVER_NEW}" -s fpm opcache (line 58), so I guess that's where the link comes from. The template php/opcache.ini.sh hardcodes the zend_extension line. I haven't read the whole script though.

    Probably the same root cause as here, only the symptom is different: "already loaded" there, missing opcache.so here.

    Not sure whether the failed zend_extension or the file_cache check is what actually kills fpm. /media/myCloudDrive was mounted.

    Suggestion: don't run phpenmod opcache on 8.5, and leave zend_extension=opcache.so (and fast_shutdown) out of the template for 8.5.

    NCP 1.59.0, Raspberry Pi 5 on raspberrypios trixie, PHP 8.5, Apache 2.4.71

  25. janvlug commented on Nov 19, 2026

    @janvlug
    Contributor

    Should this issue be reopened?

    @theCalcaholic: It seems that this issue reappeared, or was not totally solved. Should it be reopened?

  26. Knubbel commented on Nov 19, 2026

    @Knubbel

    I would like to verify, the text to insert into /usr/local/etc/ncp-templates/php/opcache.ini.sh is

    # ; priority=10
    

    with the # commenting it out, and not

    ; priority=10
    

    without the comment?

    Thank you :)

    Correct: no #.
    The # in my snippet was only a shell comment used to separate my instructions from the file content — it must not be copied into the template.
    Insert exactly this as the first line inside the cat <<EOF block:

    cat <<EOF
    ; priority=10
    zend_extension=opcache.so
    ...
    EOF

    Why it matters: the heredoc writes its lines verbatim into /etc/php/<ver>/mods-available/opcache.ini, but get_priority() in /usr/lib/php/php-helper only recognises a line starting with ; priority=. With a leading # the generated file would contain # ; priority=10, PHP would still default to priority 20 and 20-opcache.ini would reappear on the next php*-opcache update.

    Note that grep -n 'priority' matches in both cases, so use a stricter check:

    grep -n '^; priority=10' /usr/local/etc/ncp-templates/php/opcache.ini.sh
    grep -n '^; priority=10' /etc/php/8.3/mods-available/opcache.ini

    Also keep in mind that the template edit alone only takes effect the next time NCP regenerates the file (Nextcloud update, ncp-restore, data-dir change). For the current state you still need step 5.2 on the live file, plus removing the stale duplicate:

    sudo rm -f /etc/php/8.3/*/conf.d/20-opcache.ini
    sudo systemctl restart php8.3-fpm apache2

    Verification that the cause is gone (the postinst should no longer create a 20-priority link):

    sudo dpkg-reconfigure php8.3-opcache
    ls -l /etc/php/8.3/*/conf.d/*opcache*   # only 10-opcache.ini expected
    php -v 2>&1 | grep -i 'already loaded'  # no output

    One more caveat: upstream ncp-templates/php/opcache.ini.sh still lacks the priority header (checked today), so an NCP self-update can overwrite your template edit — re-check it after each ncp-update. The live mods-available/opcache.ini fix (5.2) stays active regardless.

  27. Knubbel commented on Nov 19, 2026

    @Knubbel

    Followup

    error.log is full of:
    [...]
    Probably the same root cause as here, only the symptom is different: "already loaded" there, missing opcache.so here.
    Not sure whether the failed zend_extension or the file_cache check is what actually kills fpm. /media/myCloudDrive was mounted.
    Suggestion: don't run phpenmod opcache on 8.5, and leave zend_extension=opcache.so (and fast_shutdown) out of the template for 8.5.
    NCP 1.59.0, Raspberry Pi 5 on raspberrypios trixie, PHP 8.5, Apache 2.4.71

    Thanks, that's a good catch — and your diagnosis is right, but the two errors are not equally severe, and on 8.5 the mechanism is slightly different from the 8.3 case above.

    What actually kills FPM is the second line, not the first. Since PHP 8.5 OPcache is compiled into the binary and always loaded, and the build no longer produces an opcache.so (PHP 8.5 UPGRADING, sections 1 and 9: "the build does not produce opcache.so … Using zend_extension=opcache.so … will emit a warning"). So Failed loading Zend extension 'opcache.so' is an E_WARNING only. The Fatal Error opcache.file_cache must be a full path of an accessible directory is a core error during module startup: OPcache tries to initialise its file cache, the path is not reachable (missing directory / mount not up yet / not writable), the module aborts, the FPM master exits with status 254, and systemd gives up with "Start request repeated too quickly". Removing the 20-opcache.ini "fixed" it only because that link is what made the broken ini load in the first place.

    Why the priority theory does not apply here: on 8.5 there is no php8.5-opcache package, so there is no postinst creating a 20-priority symlink. NCP creates both artefacts itself — upgrade-php-trixie-8.5.sh runs install_template "php/opcache.ini.sh" .../mods-available/opcache.ini and then phpenmod -v 8.5 -s fpm opcache. With no ; priority=10 header in the template, php-helper picks 20, hence 20-opcache.ini. Adding the header would only rename it to 10-opcache.ini — the zend_extension line would still be there, and the file_cache fatal would still happen. The header fix from above is for ≤ 8.4; on 8.5 the file simply has to go away.

    Stable setup on PHP 8.5 (running like this since 08.11.2026, 8.5.12 → current, through several php8.5-* upgrades):

    # 1. Remove the NCP-generated module file and all its links
    sudo rm -f /etc/php/8.5/mods-available/opcache.ini
    sudo rm -f /etc/php/8.5/{cli,fpm,apache2,cgi}/conf.d/*opcache.ini
    
    # 2. Put the OPcache settings in plain ini files (no zend_extension, no file_cache)
    PHPV=8.5
    for SAPI in cli fpm; do
      sudo tee /etc/php/$PHPV/$SAPI/conf.d/99-opcache-tuning.ini >/dev/null <<'EOF'
    opcache.enable=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=32
    opcache.max_accelerated_files=20000
    opcache.save_comments=1
    opcache.validate_timestamps=1
    opcache.revalidate_freq=2
    EOF
      sudo chmod 644 /etc/php/$PHPV/$SAPI/conf.d/99-opcache-tuning.ini
    done
    
    # 3. Validate, then restart (a reload is not enough for cache size changes)
    sudo php-fpm8.5 -t
    sudo systemctl reset-failed php8.5-fpm
    sudo systemctl restart php8.5-fpm apache2

    Notes on the three template lines:

    • zend_extension=opcache.so — drop it, OPcache is always loaded on 8.5.
    • opcache.fast_shutdown=1 — no-op since PHP 7.2 (directive removed), just noise.
    • opcache.file_cache=/media/.../.opcache — drop it, or make sure the directory exists and is writable at the moment PHP starts, i.e. after the mount is up (systemctl show -p RequiresMountsFor php8.5-fpm, x-systemd.automount for /media/myCloudDrive). Check with sudo -u www-data test -w <dir>. On my box the file cache was practically unused (12 KB), so it was removed — one less way to take the whole web server down at boot.

    Also relevant on 8.5: opcache.memory_consumption can no longer be changed after startup — a php_admin_value[opcache.memory_consumption] in the FPM pool config now logs a warning instead of silently being ignored (documented change in PHP 8.5). Keep the values in conf.d.

    Verification:

    php -v                                          # no "Failed loading Zend extension"
    php -m | grep -i 'Zend OPcache'                 # present, without any ini
    ls /etc/php/8.5/*/conf.d/ | grep -i opcache     # exactly 99-opcache-tuning.ini per SAPI
    php-fpm8.5 -i | grep -E 'opcache\.(interned_strings_buffer|max_accelerated_files|file_cache)'
    systemctl is-active php8.5-fpm apache2
    curl -sk https://localhost/status.php           # HTTP 200

    Suggested upstream change — the script is nearly there (PHP_PACKAGES_NEW already omits opcache); only the template call and the phpenmod are left:

    # in upgrade-php-trixie-8.5.sh (and the same for any future branch)
    if apt-cache show "php${PHPVER_NEW}-opcache" >/dev/null 2>&1; then
      install_template "php/opcache.ini.sh" "/etc/php/${PHPVER_NEW}/mods-available/opcache.ini"
      phpenmod -v "${PHPVER_NEW}" -s fpm opcache
    else
      rm -f "/etc/php/${PHPVER_NEW}/mods-available/opcache.ini"
      rm -f /etc/php/"${PHPVER_NEW}"/{cli,fpm}/conf.d/*opcache.ini
      install_template "php/opcache-tuning.ini.sh" "/etc/php/${PHPVER_NEW}/fpm/conf.d/99-opcache-tuning.ini"
    fi

    Same for the rollback branch. With the ; priority=10 header in the ≤ 8.4 template (from above) and no template/phpenmod for ≥ 8.5, both variants of this bug are gone for good. Until that lands, ncp-update re-installs the template, so re-check /etc/php/$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')/mods-available/opcache.ini after every NCP self-update.

  28. FadeFx commented on Nov 19, 2026

    @FadeFx

    The output of the verification script, if needed:

    PHP 8.5.12 (cli) (built: Oct 21 2026 08:09:42) (NTS)
    Copyright (c) The PHP Group
    Built by Debian
    Zend Engine v4.5.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies
    Zend OPcache
    Zend OPcache
    99-opcache-tuning.ini
    99-opcache-tuning.ini
    opcache.file_cache => no value => no value
    opcache.file_cache_consistency_checks => On => On
    opcache.file_cache_only => Off => Off
    opcache.file_cache_read_only => Off => Off
    opcache.interned_strings_buffer => 32 => 32
    opcache.max_accelerated_files => 20000 => 20000
    active
    active
    {"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"33.0.11.2","versionstring

  29. FadeFx commented on Nov 22, 2026

    @FadeFx

    /media/myCloudDrive was mounted.

    I have to take back that part of the analysis... I guess these messages were from a reboot of the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions