编程语言
首页 > 编程语言> > 无法将php作为apache2模块

无法将php作为apache2模块

作者:互联网

在Ubuntu服务器安装过程中,我到了需要将php作为apache2模块启用的地步.我尝试运行sudo a2enmod php5,但返回错误:模块php5不存在!

经过一番搜索,我偶然发现了Gerard的这个技巧:

如果sudo a2enmod php5返回“ $该模块不存在!”,则应清除(而不只是删除)libapache2-mod-php5软件包并重新安装.
在再次测试您的网站之前,请确保清除浏览器的缓存.”

运行sudo apt-get –purge删除libapache2-mod-php5,但是,返回的软件包libapache2-mod-php5没有安装,因此未删除.自然地,我尝试使用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 12.04下安装PHP 5.4.17,因为必需的libxml2库> = v2.8.0仅在Ubuntu 12.10(Quantal quetzal)或更高版本中可用.
解决方案:获取较新版本的Ubuntu.

标签:apache2,ubuntu-server,php
来源: https://codeday.me/bug/20191122/2063663.html