无法安装 Lamp 服务器 | 您持有损坏的软件包

无法安装 Lamp 服务器 | 您持有损坏的软件包

几天来,我一直在尝试在我的 Ubuntu 17.04 机器上安装 Lamp 服务器。当我尝试从终端安装它时,我收到此错误。

root@hp-pc:~# sudo apt install lamp-server^
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libhttp-message-perl' for task 'lamp-server'
Note, selecting 'libencode-locale-perl' for task 'lamp-server'
Note, selecting 'mysql-client-5.7' for task 'lamp-server'
Note, selecting 'libevent-core-2.0-5' for task 'lamp-server'
Note, selecting 'libapache2-mod-php' for task 'lamp-server'
Note, selecting 'rename' for task 'lamp-server'
Note, selecting 'mysql-server-5.7' for task 'lamp-server'
Note, selecting 'php-common' for task 'lamp-server'
Note, selecting 'libaprutil1' for task 'lamp-server'
Note, selecting 'mysql-server' for task 'lamp-server'
Note, selecting 'libcgi-fast-perl' for task 'lamp-server'
Note, selecting 'libwrap0' for task 'lamp-server'
Note, selecting 'libhttp-date-perl' for task 'lamp-server'
Note, selecting 'perl-modules-5.24' for task 'lamp-server'
Note, selecting 'liblwp-mediatypes-perl' for task 'lamp-server'
Note, selecting 'libfcgi-perl' for task 'lamp-server'
Note, selecting 'libcgi-pm-perl' for task 'lamp-server'
Note, selecting 'libaprutil1-dbd-sqlite3' for task 'lamp-server'
Note, selecting 'libaio1' for task 'lamp-server'
Note, selecting 'libio-html-perl' for task 'lamp-server'
Note, selecting 'ssl-cert' for task 'lamp-server'
Note, selecting 'libperl5.24' for task 'lamp-server'
Note, selecting 'libapr1' for task 'lamp-server'
Note, selecting 'libaprutil1-ldap' for task 'lamp-server'
Note, selecting 'libhtml-tagset-perl' for task 'lamp-server'
Note, selecting 'mysql-client-core-5.7' for task 'lamp-server'
Note, selecting 'tcpd' for task 'lamp-server'
Note, selecting 'liblua5.2-0' for task 'lamp-server'
Note, selecting 'mysql-common' for task 'lamp-server'
Note, selecting 'libhtml-template-perl' for task 'lamp-server'
Note, selecting 'libtimedate-perl' for task 'lamp-server'
Note, selecting 'perl' for task 'lamp-server'
Note, selecting 'php-mysql' for task 'lamp-server'
Note, selecting 'libhtml-parser-perl' for task 'lamp-server'
Note, selecting 'liburi-perl' for task 'lamp-server'
Note, selecting 'mysql-server-core-5.7' for task 'lamp-server'
Note, selecting 'php7.0-mysql' for task 'lamp-server'
libaio1 is already the newest version (0.3.110-3).
libapache2-mod-php is already the newest version (1:7.0+49).
libapr1 is already the newest version (1.5.2-5).
libaprutil1 is already the newest version (1.5.4-3).
libaprutil1-dbd-sqlite3 is already the newest version (1.5.4-3).
libaprutil1-ldap is already the newest version (1.5.4-3).
libcgi-fast-perl is already the newest version (1:2.12-1).
libcgi-pm-perl is already the newest version (4.35-1).
libencode-locale-perl is already the newest version (1.05-1).
libevent-core-2.0-5 is already the newest version (2.0.21-stable-3).
libfcgi-perl is already the newest version (0.78-2).
libhtml-parser-perl is already the newest version (3.72-3).
libhtml-tagset-perl is already the newest version (3.20-3).
libhtml-template-perl is already the newest version (2.95-2).
libhttp-date-perl is already the newest version (6.02-1).
libhttp-message-perl is already the newest version (6.11-1).
libio-html-perl is already the newest version (1.001-1).
liblua5.2-0 is already the newest version (5.2.4-1.1build1).
liblwp-mediatypes-perl is already the newest version (6.02-1).
libperl5.24 is already the newest version (5.24.1-2ubuntu1).
libtimedate-perl is already the newest version (2.3000-2).
liburi-perl is already the newest version (1.71-1).
libwrap0 is already the newest version (7.6.q-26).
perl is already the newest version (5.24.1-2ubuntu1).
perl-modules-5.24 is already the newest version (5.24.1-2ubuntu1).
php-common is already the newest version (1:49).
rename is already the newest version (0.20-4).
ssl-cert is already the newest version (1.0.38).
tcpd is already the newest version (7.6.q-26).
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.0-mysql : Depends: php7.0-common (= 7.0.15-1ubuntu4) but 7.0.22-0ubuntu0.17.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

因此我尝试手动安装该包,结果显示依赖关系未得到满足

root@hp-pc:~# apt install php7.0-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php7.0-common is already the newest version (7.0.22-0ubuntu0.17.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

因为它说包已经安装,所以我尝试手动安装 php7.0-mysql。

root@hp-pc:~# apt install php7.0-mysql
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.0-mysql : Depends: php7.0-common (= 7.0.15-1ubuntu4) but 7.0.22-0ubuntu0.17.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

为了修复损坏的包,我尝试了以下命令。

root@hp-pc:~# sudo apt-get clean
root@hp-pc:~# 

 root@hp-pc:~# sudo apt update
    Ign:1 http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty InRelease 
    Get:2 https://repo.skype.com/deb stable InRelease [4,487 B]                          
    Get:3 https://repo.skype.com/deb stable/main amd64 Packages [1,442 B]                                                                     
    Hit:4 http://us.archive.ubuntu.com/ubuntu zesty InRelease                                                                      
    Ign:5 http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/ubuntu zesty InRelease           
    Ign:6 http://dl.google.com/linux/chrome/deb stable InRelease                                       
    Hit:7 http://dl.google.com/linux/chrome/deb stable Release               
    Hit:8 http://ppa.launchpad.net/mozillateam/thunderbird-next/ubuntu zesty InRelease
    Hit:10 http://ppa.launchpad.net/obsproject/obs-studio/ubuntu zesty InRelease  
    Hit:11 http://ppa.launchpad.net/papirus/papirus/ubuntu zesty InRelease         
    Err:12 http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty Release       
      404  Not Found
    Err:13 http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/ubuntu zesty Release
      404  Not Found
    Reading package lists... Done                      
    E: The repository 'http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty Release' does not have a Release file.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    E: The repository 'http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/ubuntu zesty Release' does not have a Release file.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.

还有这个。

root@hp-pc:~# sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@hp-pc:~# 
root@hp-pc:~# sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

问题仍然没有解决。请提供建议。提前谢谢。另外请注意,我已经解决了这个问题回答。

第二天

在@zapoxkrishna 的帮助下成功修复了之前的错误。现在显示以下错误。

There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.20-0ubuntu0.17.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.20-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我使用rm命令手动删除了该文件并尝试再次安装。仍然出现相同的错误。请提供建议。

答案1

备份您现有的 sources.list,然后尝试此 sudo gedit /etc/apt/sources.list,然后删除全部内容并从此处生成新的 sources.listhttps://repogen.simplylinux.ch/并将新生成的内容粘贴到 sources.list

最后尝试这个 sudo apt-get update 然后 sudo apt install lamp-server^ 它会起作用

相关内容