在 ubuntu 12.04 上安装 apache 2.4 和 php 5.5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21390544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:06:27  来源:igfitidea点击:

Installing apache 2.4 and php 5.5 on ubuntu 12.04

phppackageubuntu-12.04apt-getapache2.4

提问by Miguel

I'm trying to set a test enviroment with apache 2.4 and php 5.5 on a vm with ubuntu 12.04, fist thing is to add the repositories

我正在尝试在带有 ubuntu 12.04 的虚拟机上使用 apache 2.4 和 php 5.5 设置测试环境,首先是添加存储库

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

Then installing apache 2.4

然后安装apache 2.4

apt-get install apache2-mpm-worker

checking apache version:

检查apache版本:

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

Installing PHP 5.5

安装 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

Checking php version

检查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

So everyting seems ok the thing is I need mod_fastcgi but can't be installed:

所以一切似乎都没问题,我需要 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.

So if mod_fastcgi can't be enabled how can I run php files with php-fpm ? Is there something I'm missing ?

因此,如果无法启用 mod_fastcgi,如何使用 php-fpm 运行 php 文件?有什么我想念的吗?

采纳答案by webdev

You can install the fastcgi mod and apache2 from here, verified that it works on my end. https://launchpad.net/~ondrej/+archive/apache2?field.series_filter=precise

你可以从这里安装 fastcgi mod 和 apache2,验证它在我这边工作。https://launchpad.net/~ondrej/+archive/apache2?field.series_filter=precise

回答by Decoded

in addition to suci and wedev's answer above, if you see an error like:

除了上面 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

because you did something dumb (like I did for example with an attempt to install php5 over top of php2.3 provided by the ubuntu image I'm working with), you can run the following commands:

因为您做了一些愚蠢的事情(就像我尝试在我正在使用的 ubuntu 映像提供的 php2.3 之上安装 php5 所做的那样),您可以运行以下命令:

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

as outlined here: https://askubuntu.com/questions/666720/ubuntu-apt-get-upgrade-error-on-ubuntu-12-04by user3703155

如此处所述:https://askubuntu.com/questions/666720/ubuntu-apt-get-upgrade-error-on-ubuntu-12-04 by user3703155

which I believe instruct the package manager to stomp over any broken dependencies regarding the apache2 installation.

我相信这会指示包管理器处理有关 apache2 安装的任何损坏的依赖项。

Subsequently running

随后运行

apt-get install -f 

followed by

其次是

apt-get dist-upgrade

and it was all happy after that.

之后就很开心了。

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