简体   繁体   中英

Pear error "XML Extension not found" on Ubuntu 14.04 after installing php-xml & php-xml7.0

I wanna use the pecl command to install redis to my php on Ubuntu 14.04. But my Pear is giving me a list of warnings:

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249
XML Extension not found

Last line gives me this message

XML Extension not found

, although I installed #sudo apt-get install php-xml php7.0-xml . But the same problem still occurs.

What could be the problem?

安装此列表,一切都会正常工作:)

sudo apt-get install php-pear pkg-config libbson-1.0 libmongoc-1.0-0 php-xml php7.0-xml php-dev

On some installations, there is a bug in pecl. Find this line;

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@" 

remove the -n

If you want to script it, try:

sed -i "$ s|\-n||g" /usr/bin/pecl

Was Facing this issue, i just needed to install php-xml

sudo apt-get install php-xml

Credits: Taha EL BOUFFI

Full Explanation as to why can be found here

Note: this is not exactly an answer to the original questions, but this might be more relevant now and in the future.

One of the possible reasons for this kind of error in more modern Ubuntu versions (like 20.04) is the possibility of having more than one version of PHP installed in the system.

Even if you install only 7.x version, and 7.x plugins and f.ex. some HTTP server like Apache it does not mean that there won't be another PHP installed. It might be installed either initially (for example in docker base image) or as a dependency of something else.

I've had such a problem in a legacy docker container which used to build and work before.

The solution was to remove PHP 8.x just before PEAR install.

sudo apt-get purge -y `apt list --installed | cut -d/ -f1 | grep php8 | awk '{print $1}' |tr "\n" " "`

or

sudo apt-get purge -y `dpkg -l | grep php8 | awk '{print $2}' |tr "\n" " "`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM