我正在尝试在已安装 apache2、php 和 mariadb 的 Ubuntu 18.04 服务器上安装 php-mbstring。我尝试了以下命令序列:
jonathan@samuel:~$ sudo apt update
[sudo] password for jonathan:
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://downloads.mariadb.com/MariaDB/mariadb-10.3/repo/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Ign:4 http://downloads.mariadb.com/MaxScale/2.2/ubuntu bionic InRelease
Hit:5 http://downloads.mariadb.com/Tools/ubuntu bionic InRelease
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:7 http://downloads.mariadb.com/MaxScale/2.2/ubuntu bionic Release
Fetched 172 kB in 2s (91.6 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
jonathan@samuel:~$ sudo apt install php-mbstring
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-mbstring : Depends: php7.2-mbstring but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
jonathan@samuel:~$ sudo apt -f install php7.2-mbstring
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.2-mbstring : Depends: php7.2-common (= 7.2.3-1ubuntu1) but 7.2.7-0ubuntu0.18.04.2 is to be installed
E: Unable to correct problems, you have held broken packages.
似乎存在无法解析的依赖项。我该如何纠正这种情况?这个问题阻止了我安装 phpMyAdmin 的尝试。
答案1
我必须在我的 sources.list 中启用 universe
sudo vi /etc/apt/sources.list
将文件更改为如下形式:
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
更新 apt-get
sudo apt update
然后我可以安装 php7.2-mbstring
答案2
我在 Ubuntu 18.04 中遇到了同样的问题#使用以下几行编辑文件 /etc/apt/sources.list:
deb http://archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe
#PHP 7.2->保存并运行:
sudo apt update && sudo apt-get upgrade
sudo apt-get install php7.2-mbstring
#PHP 7.3->保存并运行:
sudo apt update && sudo apt-get upgrade
sudo apt-get install php7.3-mbstring
完成了
答案3
简单使用:
sudo apt-get install php-mbstring
然后必须重新启动 Apache 服务,使用:
sudo service apache2 restart
答案4
试试这个我在 ubuntu 18.04 中的 php8.0 遇到了同样的问题
这将删除(所有 php7.0、7.1、7.2 等)
sudo apt-get purge php7.*
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade
sudo apt install php-mbstring