在Ubuntu 12.04上安装Apache 2.4和PHP 5.5

13

我正在尝试在Ubuntu 12.04的虚拟机上设置一个带有Apache 2.4和PHP 5.5的测试环境,第一步是添加存储库。

apt-add-repository ppa:ptn107/apache
apt-add-repository ppa:ondrej/php5

然后安装 Apache 2.4

apt-get install apache2-mpm-worker

检查 Apache 版本:

# apache2 -v
Server version: Apache/2.4.6 (Ubuntu)
Server built:   Sep 23 2013 07:23:34

安装 PHP 5.5

apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt

检查 PHP 版本

php -v
PHP 5.5.8-3+sury.org~precise+1 (cli) (built: Jan 24 2014 10:15:11) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
     with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

所以一切看起来都没问题,问题是我需要 mod_fastcgi 但无法安装:

apt-get install libapache2-mod-fastcgi
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you haverequested 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-fastcgi : Depends: apache2.2-common (>= 2.2.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
如果无法启用mod_fastcgi,我该如何使用php-fpm运行php文件?我有什么遗漏的地方吗?

稍微扩展一下,最终我没有使用 mod_fastcgi,而是使用了 ProxyPassMatch - Miguel
2个回答

11

1
使用ppa:ondrej/apache2代替ppa:ptn107/apache是有效的。现在我可以明显地看到这一点。谢谢。 - Miguel

1
除了上面suci和wedev的回答之外,如果您看到类似以下错误:
dpkg: error processing /var/cache/apt/archives/apache2-   bin_2.4.16-4+deb.sury.org~precise+4_amd64.deb (--unpack):
trying to overwrite '/usr/share/man/man8/apache2.8.gz', which is also in package apache2.2-common 2.2.22-1ubuntu1.10

如果你做了一些愚蠢的事情(就像我尝试在我正在使用的 Ubuntu 镜像上安装 php5 覆盖 php2.3 一样),你可以运行以下命令:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/apache2-bin_2.4.16-3+deb.sury.org~precise+1_amd64.deb
sudo dpkg -i --force-overwrite /var/cache/apt/archives/apache2-data_2.4.16-3+deb.sury.org~precise+1_all.deb
sudo dpkg -i --force-overwrite /var/cache/apt/archives/apache2_2.4.16-3+deb.sury.org~precise+1_amd64.deb

如此描述:https://askubuntu.com/questions/666720/ubuntu-apt-get-upgrade-error-on-ubuntu-12-04,由用户3703155提出。

我认为这些指令会告诉软件包管理器覆盖有关Apache2安装的任何损坏依赖关系。

随后运行

apt-get install -f 

跟随着

,然后是


apt-get dist-upgrade

然后一切都很愉快。

php -version
PHP 5.5.30-1+deb.sury.org~precise+1 (cli) (built: Oct  4 2015 16:14:34) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with XCache v3.2.0, Copyright (c) 2005-2014, by mOo
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with XCache Optimizer v3.2.0, Copyright (c) 2005-2014, by mOo
with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo
with XCache Coverager v3.2.0, Copyright (c) 2005-2014, by mOo

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