我最初在安装服务器时安装了 LAMP 包。我花了很长时间才让 Web 服务器工作起来,然后我发现 PHP 并没有作为包的一部分安装,这很奇怪,因为它本应如此。我还尝试安装 SSH 服务器,以便我可以使用 Putty 登录。每次我尝试安装任何东西时,我都会得到以下信息:-
jim@Unseen:~$ sudo apt-get -f install php libapache2-mod-php php-mcrypt php-mysq
l
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php is already the newest version (1:7.0+35ubuntu6.1).
php-mysql is already the newest version (1:7.0+35ubuntu6.1).
The following additional packages will be installed:
libmcrypt4 php7.0 php7.0-mcrypt
Suggested packages:
libmcrypt-dev mcrypt
The following NEW packages will be installed
libmcrypt4 php php-mcrypt php7.0 php7.0-mcrypt
0 to upgrade, 5 to newly install, 0 to remove and 0 not to upgrade.
Need to get 0 B/83.5 kB of archives.
After this operation, 326 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
E: Waited for /usr/sbin/dpkg-preconfigure --apt || true but it wasn't there
E: Failure running script /usr/sbin/dpkg-preconfigure --apt || true
我试过 apt-get clean。我试过标准 apt-get。我运行过 apt-get update。我试过的所有方法似乎都不起作用。有人能给我提点建议吗?我是 ubuntu 新手,用起来很沮丧。提前谢谢
编辑:
我尝试了类似帖子中建议的修复方法,该帖子涉及 14.0*,但我的服务器是 16.04.4:-
sudo sh -c "echo 'DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};' >> /etc/apt/apt.conf.d/70debconf"
这不起作用并报告 70debconf 不存在。
编辑2
我按照建议将命令字符串更正为:-
sudo sh -c "echo 'DPkg::Pre-Install-Pkgs {\"/usr/sbin/dpkg-preconf
igure --apt || true\";};' >> /etc/apt/apt.conf.d/70debconf"
它返回了一个提示,但没有消息,所以我假设它起作用了
然后我运行了以下命令:-
sudo apt-get install openssh-server
并返回与之前完全相同的结果:-
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ncurses-term openssh-sftp-server python3-requests python3-urllib3
ssh-import-id
Suggested packages:
ssh-askpass rssh molly-guard monkeysphere python3-ndg-httpsclient
python3-openssl python3-pyasn1
The following NEW packages will be installed
ncurses-term openssh-server openssh-sftp-server python3-requests
python3-urllib3 ssh-import-id
0 to upgrade, 6 to newly install, 0 to remove and 0 not to upgrade.
Need to get 0 B/746 kB of archives.
After this operation, 5,652 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
E: Waited for /usr/sbin/dpkg-preconfigure --apt || true but it wasn't there
E: Failure running script /usr/sbin/dpkg-preconfigure --apt || true
编辑3
在得到一些极好的帮助后,我突然想到了一个主意。在这些问题出现之前,我安装了 Webmin,以便从我的桌面快速远程访问服务器。我尝试通过 webmin 安装 Openssh-server,令我惊讶的是,它成功了。所以结论似乎是 webmin 以某种方式干扰了服务器上的本机功能。我确信这不应该发生,不知道我是否应该报告。
答案1
初始答案有问题,内部双引号需要转义
sudo sh -c "echo 'DPkg::Pre-Install-Pkgs {\"/usr/sbin/dpkg-preconfigure --apt || true\";};' >> /etc/apt/apt.conf.d/70debconf"
我可以确认 /etc/apt/apt.conf.d/70debconf 在我的 Ubuntu 16.04 和 Ubuntu 17.10 机器上都存在。在我的 Ubuntu 16.04 机器上,此文件的内容如下
// Pre-configure all packages with debconf before they are installed.
// If you don't like it, comment it out.
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};