php 7 install抛出“无法加载Zend OPcache-已加载”错误


15

我正在使用salt我的服务器进行配置,我只是尝试升级到php 7,尽管一切都正确安装,但是无论何时我运行php -v或运行任何php,它都会在任何输出的开头:Cannot load Zend OPcache - it was already loaded。如果看到此提示我将其卸载,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-v和未php-opcache安装的完整输出。

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

带出

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

我以此安装(在盐状态文件中)

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

而且我知道它是根据7.0 yum install php-opcache然后从7.0回购安装的php -v

终端输出

[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

我根本找不到与此相关的任何信息。任何想法都很棒。

可能有用的注意事项:
  1. 这是一个vagrant加载CentOS 6.5 的服务器
  2. 通过以下方式提供资源 salt
  3. salt运行时安装干净

更新

因此,我尝试安装Zen Opcache并认为它已与php 7兼容,但事实并非如此。我正在尝试查看正在加载的内容,或者我提供的opcache.ini文件是否存在问题。也许在该区域php5移到了php 7时有一些新设置。

Answers:


18

原来,我正在加载的opcache.ini文件是php 5默认使用的文件,但是在php 7中它是10-opcache.ini默认加载的,因此在配置我的opcache.ini文件时,它有两个.ini文件,并尝试两次加载插件。

我不会删除此问题,因为我认为这是一个容易忽略的错误,可能会有所帮助,因为您无法真正在Google上找到该错误阶段,而且没有一个地方写有任何关于double ini文件的信息或两次声明扩展名。


在升级到以下版本之后,今天也对我也是如此: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

6
同样的事情,今天用PHP7也发生在我身上。我运行ls -la /etc/php/7.0/cli/conf.d并确定,那里有两个opcache符号链接:10-opcache.ini20-opcache.ini。这两个20-opcache.ini中的时间戳比较旧,因此我删除了该符号链接(sudo rm /etc/php/7.0/cli/conf.d/20-opcache.ini),现在一切都很好。谢谢!
加布里埃尔·麦格纳

1
因此,事实证明这是php 7.0.3.1中的一个错误,并已由7.0.3.2修复,请参阅launchpad.net/ubuntu/+source/php7.0/7.0.3-2
Boyd

我确认它现已修复
greg606 '16

那很有用。就我而言,我不知道为什么,我在php7.0上同时使用05-opcache.ini和10-opcache.ini。我删除了第二个,警告消失了。如果有什么问题,我会在这里评论。在Ubuntu上使用PHP 7.0.15。
Dominic108 '17
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.