How to fix PHP warning: Cannot load Zend OPcache – extension already loaded


If you see this warning like this:

[root@tutorialspots ~]# php -v
Cannot load Zend OPcache - extension already loaded
PHP 5.6.40 (cli) (built: Jul 30 2019 10:51:23)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

or

[root@tutorialspots ~]# service php-fpm status
Redirecting to /bin/systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/php-fpm.service.d
           └─limit.conf
   Active: active (running) since Wed 2019-08-07 13:37:26 +04; 4s ago
 Main PID: 31585 (php-fpm)
   Status: "Ready to handle connections"
   CGroup: /system.slice/php-fpm.service
           └─31585 php-fpm: master process (/etc/php-fpm.conf)

Aug 07 13:37:26 vps.tutorialspots.com systemd[1]: Stopped The PHP FastCGI Process Manager.
Aug 07 13:37:26 vps.tutorialspots.com systemd[1]: Starting The PHP FastCGI Process Man....
Aug 07 13:37:26 vps.tutorialspots.com php-fpm[31585]: Cannot load Zend OPcache - exten...d
Aug 07 13:37:26 vps.tutorialspots.com systemd[1]: Started The PHP FastCGI Process Manager.
Hint: Some lines were ellipsized, use -l to show in full.

php warning opcache

See your PHP config folder:

[root@tutorialspots ~]# ls /etc/php.d
10-opcache.ini   20-iconv.ini      20-sockets.ini    30-pdo_sqlite.ini
20-bz2.ini       20-intl.ini       20-sqlite3.ini    30-wddx.ini
20-calendar.ini  20-ldap.ini       20-sysvmsg.ini    30-xmlreader.ini
20-ctype.ini     20-mbstring.ini   20-sysvsem.ini    40-igbinary.ini
20-curl.ini      20-mcrypt.ini     20-sysvshm.ini    40-json.ini
20-dom.ini       20-mysqlnd.ini    20-tokenizer.ini  40-memcache.ini
20-enchant.ini   20-pdo.ini        20-xml.ini        40-msgpack.ini
20-exif.ini      20-pgsql.ini      20-xmlwriter.ini  40-zip.ini
20-fileinfo.ini  20-phar.ini       20-xsl.ini        50-memcached.ini
20-ftp.ini       20-posix.ini      30-mysqli.ini     opcache.ini
20-gd.ini        20-shmop.ini      30-mysql.ini
20-gettext.ini   20-simplexml.ini  30-pdo_mysql.ini
20-gmp.ini       20-soap.ini       30-pdo_pgsql.ini

You see two files:

[root@tutorialspots ~]# ls /etc/php.d |grep opcache
10-opcache.ini
opcache.ini

Delete file 10-opcache.ini, then restart PHP-FPM

service php-fpm restart

Recent search terms:

  • php --version PHP Warning: Failed loading Zend extension opcache so

Leave a Reply