15

I am using salt to provision my servers, and I just tried to upgrade to php 7 and although everything is installing correctly, anytime I run php -v or run any php anything it throw this at the head of any output: Cannot load Zend OPcache - it was already loaded. If I uninstall if I see this, Failed loading /usr/lib64/php/modules/opcache.so: /usr/lib64/php/modules/opcache.so: cannot open shared object file: No such file or directory

Here is the full output from php-v with and with out the php-opcache installed.

With

Cannot load Zend OPcache - it was already loaded
PHP 7.0.1 (cli) (built: Dec 16 2015 15:31:55) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.4.0RC3, Copyright (c) 2002-2015, by Derick Rethans

With out

Failed loading /usr/lib64/php/modules/opcache.so:  /usr/lib64/php/modules/opcache.so: cannot open shared object file: No such file or directory
PHP 7.0.1 (cli) (built: Dec 16 2015 15:31:55) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.4.0RC3, Copyright (c) 2002-2015, by Derick Rethans

I install with this (in the salt state file)

remi-php70-repo:
  pkgrepo.managed:
    - humanname: Remi PHP 7 Repository
    - baseurl: http://rpms.famillecollet.com/enterprise/$releasever/php70/$basearch/
    - gpgcheck: 0
    - require_in:
      - pkg: php-fpm

php-fpm:
  pkg.latest:
    - pkgs:
      - php-fpm

php-opcache:
  pkg.latest:
    - pkgs:
      - php-opcache

And I know it is installing from the 7.0 repo based on a yum install php-opcache and then a php -v

terminal output

[root@mage2appblock vagrant]# yum install php-opcache
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                    |  14 kB     00:00
 * base: mirror.spro.net
 * epel: mirrors.cat.pdx.edu
 * extras: mirror.keystealth.org
 * updates: mirror-centos.hostingswift.com
base                                                                                             | 3.7 kB     00:00
centos-plus-repo                                                                                 | 3.4 kB     00:00
epel                                                                                             | 4.3 kB     00:00
epel/primary_db                               35% [============-                      ]  0.0 B/s | 2.1 MB     --:-- ETA epel/primary_db                                                                                  | 5.7 MB     00:00
extras                                                                                           | 2.9 kB     00:00
mysql56-community-repo                                                                           | 2.5 kB     00:00
remi-php70-repo                                                                                  | 2.9 kB     00:00
remi-rep                                                                                         | 2.9 kB     00:00
remi-rep/primary_db                            7% [==                                 ]  0.0 B/s |  97 kB     --:-- ETA remi-rep/primary_db                           37% [=============                      ] 655 kB/s | 510 kB     00:01 ETA remi-rep/primary_db                                                                              | 1.3 MB     00:00
repo-saltstack-el6                                                                               | 2.9 kB     00:00
updates                                                                                          | 3.4 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package php-opcache.x86_64 0:7.0.1-1.el6.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                    Arch                  Version                          Repository                      Size
========================================================================================================================
Installing:
 php-opcache                x86_64                7.0.1-1.el6.remi                 remi-php70-repo                135 k

Transaction Summary
========================================================================================================================
Install       1 Package(s)

Total download size: 135 k
Installed size: 378 k
Is this ok [y/N]: y
Downloading Packages:
php-opcache-7.0.1-1.el6.remi.x86_64.rpm       18% [======-                            ]  0.0 B/s |  25 kB     --:-- ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       31% [===========                        ]  27 kB/s |  43 kB     00:03 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       38% [=============-                     ]  28 kB/s |  52 kB     00:02 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       48% [================-                  ]  29 kB/s |  65 kB     00:02 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       55% [===================-               ]  29 kB/s |  75 kB     00:02 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       69% [========================           ]  31 kB/s |  94 kB     00:01 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm       90% [===============================-   ]  35 kB/s | 122 kB     00:00 ETA php-opcache-7.0.1-1.el6.remi.x86_64.rpm                                                          | 135 kB     00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-opcache-7.0.1-1.el6.remi.x86_64                                                                  1/1
  Verifying  : php-opcache-7.0.1-1.el6.remi.x86_64                                                                  1/1

Installed:
  php-opcache.x86_64 0:7.0.1-1.el6.remi

Complete!
[root@mage2appblock vagrant]# php -v
Cannot load Zend OPcache - it was already loaded
PHP 7.0.1 (cli) (built: Dec 16 2015 15:31:55) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.4.0RC3, Copyright (c) 2002-2015, by Derick Rethans

I have not be able to find anything related on this at all. Any ideas would be great.

Notes that may be helpful:
  1. This is a vagrant server loading CentOS 6.5
  2. Provisioning is provided via salt
  3. the install is clean when salt runs

Updates

So I have tried with out installing the Zen Opcache thinking it was complied in with php 7, it is not. I am trying to look at what is loading or if there is some issue with the opcache.ini file I provision in. Maybe there is some new settings with the php5 moving to php 7 in that area.

18

Turns out that I was loading a opcache.ini file which was what php 5 used by default, but in php 7 it was loaded as 10-opcache.ini by default so when my file of opcache.ini was provisioned in it had two .ini files and was trying to load the plugin twice.

I'm not going to delete this question as I believe it is an error that is easy to overlook and may be helpful since you can't really google that error phase and not one place that had anything on it said anything about doubled ini files or declaring the extension twice.

  • Happend to me as well today after I upgraded to: php7.0-cli 7.0.3-1+deb.sury.org~trusty+1 php7.0-common 7.0.3-1+deb.sury.org~trusty+1 php7.0-fpm 7.0.3-1+deb.sury.org~trusty+1 php7.0-gd 7.0.3-1+deb.sury.org~trusty+1 php7.0-json 7.0.3-1+deb.sury.org~trusty+1 php7.0-mysql 7.0.3-1+deb.sury.org~trusty+1 php7.0-opcache 7.0.3-1+deb.sury.org~trusty+1 php7.0-readline 7.0.3-1+deb.sury.org~trusty+1 – Boyd Feb 6 '16 at 20:31
  • 6
    Same thing, happened to me as well today with PHP7. I ran ls -la /etc/php/7.0/cli/conf.d and sure enough, there were two opcache symlinks in there: 10-opcache.ini and 20-opcache.ini. Out of the two 20-opcache.ini had the older timestamp, so I erased that symlink (sudo rm /etc/php/7.0/cli/conf.d/20-opcache.ini), and all is well now. Thanks! – Gabriel Magana Feb 6 '16 at 23:00
  • 1
    So it turns out it was a bug in php 7.0.3.1 and is fixed by 7.0.3.2 see launchpad.net/ubuntu/+source/php7.0/7.0.3-2 – Boyd Feb 8 '16 at 8:52
  • I confirm it's fixed now – greg606 Feb 10 '16 at 12:31
  • That was useful. In my case, I don't know why, I had on php7.0, both 05-opcache.ini and 10-opcache.ini. I removed the second and the warning disapeared. I'll comment back here, if it breaks something. Using PHP 7.0.15 on Ubuntu. – Dominic108 Apr 16 '17 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.