无法将PHP作为Apache2模块启用

6
在Ubuntu服务器设置过程中,我需要启用php作为apache2模块。 我尝试运行sudo a2enmod php5,但它返回了ERROR: Module php5 does not exist! 经过一番搜索,我偶然发现了gerard所提供的提示:
如果sudo a2enmod php5返回"$ This module does not exist!",则应该清除(而不仅仅是删除)libapache2-mod-php5软件包并重新安装它。确保在重新测试网站之前清除浏览器缓存。 然而,运行sudo apt-get --purge remove libapache2-mod-php5后,却返回Package libapache2-mod-php5 is not installed, so not removed。自然地,我尝试使用sudo apt-get install libapache2-mod-php5进行安装,但随即收到以下信息:
    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.
    libapache2-mod-php5 : Depends: libxml2 (>= 2.8.0) but 2.7.8.dfsg-5.1ubuntu4.6 is to be installed
    Recommends: php5-cli but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

我尝试通过升级更新来更新 libxml2,但没有成功。我还尝试安装 php5-cli,但遇到了以下问题:
    The following packages have unmet dependencies.
    php5-cli : Depends: libxml2 (>= 2.8.0) but 2.7.8.dfsg-5.1ubuntu4.6 is to be installed
               Depends: libedit2 (>= 2.11-20080614-4) but 2.11-20080614-3ubuntu2 is to be installed
    E: Unable to correct problems, you have held broken packages.

目前我有些迷失。运行php -v命令,显示PHP正在运行,但是:

    PHP 5.4.17 (cli) (built: Aug  7 2013 11:40:38) 
    Copyright (c) 1997-2013 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

你安装的是哪个Ubuntu版本? - ciruvan
2个回答

5

在Ubuntu 12.04下,你无法安装PHP 5.4.17,因为所需的libxml2库>= v2.8.0仅在Ubuntu 12.10(Quantal quetzal)或更高版本中可用。 解决方法:获取更新版本的Ubuntu。


我可以直接升级吗?或者这样做现在没有帮助? - Evaldas Raisutis
我从未升级过Ubuntu,我总是重新安装。但如果有办法,请尝试一下。祝你好运! - ciruvan
谢谢,我还是会尝试的,毕竟这只是一个虚拟机 :) - Evaldas Raisutis
你可以轻松升级它 :) - Mantas

0

哦不!您必须使用aptitude -y install php5 libapache2-mod-php5 php5-mysql php5-gd来安装带有Apache的php5。 libapache2-mod-php5是Apache的一个模块,但您必须安装php5才能编译php代码。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接