无法在 Ubuntu 16.04 LTS 上安装 php

无法在 Ubuntu 16.04 LTS 上安装 php
Creating config file /etc/php/7.0/cli/php.ini with new version
Setting up php7.0-fpm (7.0.8-0ubuntu0.16.04.3) ...
Not replacing deleted config file /etc/php/7.0/fpm/php.ini
insserv: warning: script 'K01jira' missing LSB tags and overrides
insserv: warning: script 'nagios' missing LSB tags and overrides
insserv: warning: script 'jira' missing LSB tags and overrides
Job for php7.0-fpm.service failed because the control process exited with error code. See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details.
invoke-rc.d: initscript php7.0-fpm, action "start" failed.
dpkg: error processing package php7.0-fpm (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of php7.0:
 php7.0 depends on php7.0-fpm | libapache2-mod-php7.0 | php7.0-cgi; however:
  Package php7.0-fpm is not configured yet.
  Package libapache2-mod-php7.0 is not installed.
  Package php7.0-cgi is not installed.

dpkg: error processing package php7.0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php:
 php depends on php7.0; however:
  Package php7.0 is not configured yet.

dpkg: error processing package php (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates it's a follow-up error from a previous failure.
    No apport report written because the error message indicates it's a follow-up error from a previous failure.
        Errors were encountered while processing:
 php7.0-fpm
 php7.0
 php
E: Sub-process /usr/bin/dpkg returned an error code (1)

我刚刚从 Ubuntu 14.04 升级到 16.04。升级之前,我们彻底删除了 mysql 和 php,打算之后再安装新版本。

我们安装了全新的 apache 和 mysql 服务器,没有任何问题。但当涉及到 php 时,我们一直受到上述警告的困扰。

我们刚刚遵循的指南是https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

如何解决这个问题并安装 php?

答案1

好的,我找到了一个适合我的解决方案......

cd /var/lib/dpkg/info
rm *.postinst
apt-get --force-yes install openjdk-7-jre-headless

我只是假设由于 openjdk 已经安装,这只是一个开始,它不一定是 openjdk。

然后我继续清除 apache 和 php

apt-get purge apache2
apt-get purge php
apt-get autoremove
apt-get autoclean
rm -R /etc/apache2 /etc/php

然后我可以再次干净地安装 apache2 和 php,一切都很顺利 apt-get install apache2 apt-get install php

真令人头痛。dpkg --configure -a什么也没做,一直说初始依赖错误,就像我能找到的所有其他解决方案一样。

答案2

我认为,如果您想安装 php7 和 php7 模块,您必须执行sudo apt-get install php7sudo apt-get install php7-x。 或者php5。 而在文章中他们说sudo apt-get install php并没有声明版本。

还请查看博客上的评论部分,很多人都有错误,并且针对这些错误提供了解决方案。

相关内容