PHP 7 模块已加载警告

PHP 7 模块已加载警告

我有一台运行 Ubuntu 14.04.3 LTS 的机器,它是通过 Ansible 部署的。我使用以下方法安装了 PHP 7Ondřej Surý 的 PHP PPA

$ dpkg -l | grep -i php
ii  libapache2-mod-php7.0            7.0.3-2+deb.sury.org~trusty+1    amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-common                       1:36+deb.sury.org~trusty+1       all          Common files for PHP packages
ii  php7.0                           7.0.4-6+deb.sury.org~trusty+1    all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.0-cli                       7.0.0-5+deb.sury.org~trusty+1    amd64        command-line interpreter for the PHP scripting language
ii  php7.0-common                    7.0.4-6+deb.sury.org~trusty+1    amd64        documentation, examples and common module for PHP
ii  php7.0-fpm                       7.0.4-6+deb.sury.org~trusty+1    amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.0-json                      7.0.0-5+deb.sury.org~trusty+1    amd64        JSON module for PHP
ii  php7.0-opcache                   7.0.0-5+deb.sury.org~trusty+1    amd64        Zend OpCache module for PHP
ii  php7.0-pgsql                     7.0.4-6+deb.sury.org~trusty+1    amd64        PostgreSQL module for PHP

警告

当 cron 运行时/usr/lib/php/sessionclean,我收到以下警告:

PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
PHP Warning:  Module 'calendar' already loaded in Unknown on line 0
PHP Warning:  Module 'ctype' already loaded in Unknown on line 0
PHP Warning:  Module 'exif' already loaded in Unknown on line 0
PHP Warning:  Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning:  Module 'ftp' already loaded in Unknown on line 0
PHP Warning:  Module 'gettext' already loaded in Unknown on line 0
PHP Warning:  Module 'iconv' already loaded in Unknown on line 0
PHP Warning:  Module 'Phar' already loaded in Unknown on line 0
PHP Warning:  Module 'posix' already loaded in Unknown on line 0
PHP Warning:  Module 'sockets' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning:  Module 'tokenizer' already loaded in Unknown on line 0
PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
PHP Warning:  Module 'calendar' already loaded in Unknown on line 0
PHP Warning:  Module 'ctype' already loaded in Unknown on line 0
PHP Warning:  Module 'exif' already loaded in Unknown on line 0
PHP Warning:  Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning:  Module 'ftp' already loaded in Unknown on line 0
PHP Warning:  Module 'gettext' already loaded in Unknown on line 0
PHP Warning:  Module 'iconv' already loaded in Unknown on line 0
PHP Warning:  Module 'Phar' already loaded in Unknown on line 0
PHP Warning:  Module 'posix' already loaded in Unknown on line 0
PHP Warning:  Module 'sockets' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning:  Module 'tokenizer' already loaded in Unknown on line 0
PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
PHP Warning:  Module 'calendar' already loaded in Unknown on line 0

运行时php -v我收到以下警告的一部分:

PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
PHP Warning:  Module 'calendar' already loaded in Unknown on line 0
PHP Warning:  Module 'ctype' already loaded in Unknown on line 0
PHP Warning:  Module 'exif' already loaded in Unknown on line 0
PHP Warning:  Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning:  Module 'ftp' already loaded in Unknown on line 0
PHP Warning:  Module 'gettext' already loaded in Unknown on line 0
PHP Warning:  Module 'iconv' already loaded in Unknown on line 0
PHP Warning:  Module 'Phar' already loaded in Unknown on line 0
PHP Warning:  Module 'posix' already loaded in Unknown on line 0
PHP Warning:  Module 'sockets' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning:  Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning:  Module 'tokenizer' already loaded in Unknown on line 0

偶尔我会在 CodeIgniter 的日志中看到以下行:

Severity: Core Warning --> Module 'tokenizer' already loaded Unknown 0

配置文件

extension=...这个错误并不是一个新错误,所以我还有很多其他问题需要研究,但他们建议的解决方案是确保我的代码中没有重复的行php.ini,但没有。

这里是 中的所有文件/etc/php。有一堆ini链接到多个地方的单个模块的文件很可能会导致问题。

/etc/php/mods-available/json.ini
/etc/php/mods-available/opcache.ini
/etc/php/7.0/fpm/php-fpm.conf
/etc/php/7.0/fpm/conf.d/* -> /etc/php/7.0/mods-available/*
/etc/php/7.0/fpm/pool.d
/etc/php/7.0/fpm/pool.d/www.conf
/etc/php/7.0/fpm/php.ini
/etc/php/7.0/cli/conf.d/* -> /etc/php/7.0/mods-available/*
/etc/php/7.0/cli/php.ini
/etc/php/7.0/apache2/php.ini.ucf-dist
/etc/php/7.0/apache2/conf.d/* -> /etc/php/7.0/mods-available/*
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/mods-available/fileinfo.ini
/etc/php/7.0/mods-available/pdo_pgsql.ini
/etc/php/7.0/mods-available/sockets.ini
/etc/php/7.0/mods-available/exif.ini
/etc/php/7.0/mods-available/shmop.ini
/etc/php/7.0/mods-available/ctype.ini
/etc/php/7.0/mods-available/sysvshm.ini
/etc/php/7.0/mods-available/gettext.ini
/etc/php/7.0/mods-available/ftp.ini
/etc/php/7.0/mods-available/sysvmsg.ini
/etc/php/7.0/mods-available/calendar.ini
/etc/php/7.0/mods-available/iconv.ini
/etc/php/7.0/mods-available/pdo.ini
/etc/php/7.0/mods-available/phar.ini
/etc/php/7.0/mods-available/posix.ini
/etc/php/7.0/mods-available/tokenizer.ini
/etc/php/7.0/mods-available/pgsql.ini
/etc/php/7.0/mods-available/sysvsem.ini

我需要删除哪些文件才能停止警告而不停止 PHP 工作(通过 Web 和 CLI)?(如果可以通过 Ansible 轻松完成则可获得加分)

答案1

尝试将 /etc/php/7.0/mods-available/ 中的 .ini 文件重命名为 nameofthemodule.ini.back

例如:sudo mv tokenizer.ini tokenizer.ini.back

重新启动 php,然后检查 php -m 并检查该模块的警告是否消失。

似乎在安装扩展时也会安装 php-common,然后此安装会为所包含的扩展创建新的 .ini 文件。但这些扩展已在 php 二进制文件中编译。

谨慎处理,以上段落仅是猜测。

相关内容