【问题标题】:Can't enable php as apache2 module无法启用 php 作为 apache2 模块
【发布时间】:2013-08-08 19:51:02
【问题描述】:

在 Ubuntu 服务器设置期间,我需要启用 php 作为 apache2 模块。我尝试运行sudo a2enmod php5,但它返回了ERROR: Module php5 does not exist!

经过一番搜索,我偶然发现了 gerard 的这个提示:

如果 sudo a2enmod php5 返回“$ 这个模块不存在!”,你应该清除(不仅仅是删除)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.

我试图更新 && upgrade 希望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 版本?

标签: php apache2 ubuntu-server


【解决方案1】:

哦不!你必须使用 aptitude -y 安装 php5 libapache2-mod-php5 php5-mysql php5-gd 用 apache 安装 php5。 libapache2-mod-php5是apache的一个模块,但是编译php代码需要安装php5

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 我假设我可以直接升级?还是此时无济于事?
    • 我从未升级过 ubuntu,我总是重新安装。但如果有办法,请继续尝试。 :) 祝你好运!
    • 谢谢,我会试试的,它只是一个虚拟机:)
    • 你可以轻松升级它:)
    猜你喜欢
    • 2014-09-26
    • 2017-06-14
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    • 2017-12-20
    • 1970-01-01
    相关资源
    最近更新 更多