Ubunutu 12.04 上 PHP 升级失败,错误:子进程 /usr/bin/dpkg 返回错误代码 (1)

Ubunutu 12.04 上 PHP 升级失败,错误:子进程 /usr/bin/dpkg 返回错误代码 (1)

我刚刚尝试在 Ubuntu 12.04 上升级我的 PHP 版本,但现在却搞砸了。首先我这样做:

sudo add-apt-repository ppa:ondrej/php5-oldstable

然后我这样做了:

sudo apt-get update

最后我这样做了:

sudo apt-get install php5

现在我收到一条错误消息Sub-process /usr/bin/dpkg returned an error code (1)

我做错了什么?我该如何解决这个问题?谢谢。

以下是收到的错误:

Do you want to continue [Y/n]? Y
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
Setting up libapache2-mod-php5 (5.4.28-1+deb.sury.org~precise+1) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing libapache2-mod-php5 (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Setting up php5-cli (5.4.28-1+deb.sury.org~precise+1) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing php5-cli (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php5-curl:
 php5-curl depends on phpapi-20100525+lfs; however:
  Package phpapi-20100525+lfs is not installed.
  Package libapache2-mod-php5 which provides phpapi-20100525+lfs is not configured yet.
  Package php5-cli which provides phpapi-20100525+lfs is not configured yet.
dpkg: error processing php5-curl (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php5-gd:
 php5-gd depends on phpapi-20100525+lfs; however:
  Package phpapi-20100525+lfs is not installed.
  Package libapache2-mod-php5 which provides phpapi-20100525+lfs is not configured yet.
  Package php5-cli which provides phpapi-20100525+lfs is not configured yet.
dpkg: error processing php5-gd (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php5-mcrypt:
 php5-mcrypt depends on phpapi-20100525+lfs; however:
  Package phpapi-20100525+lfs is not installed.
  Package libapache2-mod-php5 which provides phpapi-20100525+lfs is not configured yet.
  Package php5-cli which provides phpapi-20100525+lfs is not configured yet.
dpkg: error processing php5-mcrypt (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php5-mysql:
 php5-mysql depends on phpapi-20100525+lfs; however:
  Package phpapi-20100525+lfs is not installed.
  Package libapache2-mod-php5 which provides phpapi-20100525+lfs is not configured yet.
  Package php5-cli which provides phpapi-20100525+lfs is not configured yet.
dpkg: error processing php5-mysql (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php5:
 php5 depends on libapache2-mod-php5 (>= 5.4.28-1+deb.sury.org~precise+1) | libapache2-mod-php5filter (>= 5.4.28-1+deb.sury.org~precise+1) | php5-cgi (>= 5.4.28-1+deb.sury.org~precise+1) | php5-fpm (>= 5.4.28-1+deb.sury.org~precise+1); however:
  Package libapache2-mod-php5 is not configured yet.
  Package libapache2-mod-php5filter is not installed.
  Package php5-cgi is not installed.
  Package php5-fpm is not installed.
dpkg: error processing php5 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 libapache2-mod-php5
 php5-cli
 php5-curl
 php5-gd
 php5-mcrypt
 php5-mysql
 php5
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我通过阅读错误消息并看到以下内容设法解决了该问题:

DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable

为了从这个文件中删除锁,我做了以下事情:

sudo fuser -v /var/cache/debconf/config.dat

然后,在执行此操作后,我了解了哪个进程正在使用该 config.dat 文件。然后我执行以下操作来终止特定进程(我的进程是 30773):

sudo kill 30773

完成此操作后,我就能够使用以下命令正确安装 PHP:

sudo apt-get install php5

然后一切就正常了。谢谢你给我指明了正确的方向。

相关内容