如何在Ubuntu上安装PHP 7(下一代PHP) [英] How do I install PHP 7 (PHP next generation) on Ubuntu

查看:59
本文介绍了如何在Ubuntu上安装PHP 7(下一代PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Ubuntu上安装PHP 7(下一代PHP)?

How do I install PHP 7 (PHP next generation) on Ubuntu?

我想在全新安装的Ubuntu上安装PHP 7,以了解我将面临的问题.

I wanted to install PHP 7 on a clean install of Ubuntu to see what issues I would face.

这是官方(但微薄的指南):

Here’s the official (yet meager guide):

https://wiki.php.net/phpng

推荐答案

我自己进行了一次遍历,并认为记录下我遇到的问题以及克服这些问题的方式将非常有用,这样可以节省其他人也许有些痛苦和苦难.

I did a run through on my own, and thought it would be useful to document what problems I ran into as I went and how I overcame them thus saving others perhaps some pain and suffering.

但是我(事后)确实找到了这个

I did however (after the fact) find this http://jcutrer.com/howto/linux/how-to-compile-php7-on-ubuntu-14-04 which is a much cleaner guide than what I provide below.

从指南( https://wiki.php.net/phpng ):

From the guide (https://wiki.php.net/phpng):

./buildconf 
mkdir  ~/tmp 
cd ~/tmp
git clone https://git.php.net/repository/php-src.git
cd php-src

到目前为止,一切都很好.此时,我开始遇到问题:

So far so good. At this point I started having problems:

./buildconf

./buildconf

报告我没有安装make.解决方案在这里找到: ​​ https://askubuntu.com/questions/192645/make-command-not-found

Reported that I did not have make installed. The solution was found here: https://askubuntu.com/questions/192645/make-command-not-found

我尝试了这个,但是仍然有问题,所以我这样做:

I tried this, but still had problems so I did this:

sudo apt-get purge make  
sudo apt-get install make 

当我再次尝试./buildconf时,出现下一个问题,它抱怨我没有自动配置.解决方法如下:

Next problem when I tried ./buildconf again it complained that I did not have autoconfig. Here’s the solution to that:

sudo apt-get install autoconf  

现在终于可以运行./configure命令并得到了:

Now finally got to run ./configure command and got this:

配置:警告:如果需要,您将需要re2c 0.13.4或更高版本 重新生成PHP解析器.配置:错误:需要安装野牛 建立GIT结帐时使用PHP/Zend!

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. configure: error: bison is required to build PHP/Zend when building a GIT checkout!

安装Bison似乎也要安装re2c,因此可以解决两个问题:

Installing Bison also appears to install re2c as well so this fixes both problems:

sudo apt-get install bison    

配置搅动了一段时间,然后通过以下方式将其吐出:

Config churned along for quite some time and then puked with:

配置:错误:找不到xml2-config.请检查您的libxml2安装.

configure: error: xml2-config not found. Please check your libxml2 installation.

应该很容易解决吗?只需运行:

Should be an easy fix right? Just run:

sudo apt-get install libxml2

不.没那么容易.我们已经有了最新和最出色的功能:

Nope. Not that easy. We already have the latest and greatest for this:

libxml2已经是最新版本.

libxml2 is already the newest version.

好的.也许我们可以像制作,清除和重新安装后一样解决此问题:

Okay. Maybe we can solve this like we did make and purge and reinstall:

sudo apt-get清除libxml2 sudo apt-get install libxml2

sudo apt-get purge libxml2 sudo apt-get install libxml2

不.在同一错误上运行./configure barfs.如此抢救:

Nope. Running ./configure barfs on the same error. SO to the rescue:

如何修复从源代码安装PHP时找不到的xml2-config错误?

显然,我们需要该库的开发版本:

Aparently we need the development version of this library:

sudo apt-get install libxml2-dev

./再次配置,我们已经取得进展...一个新错误:

./configure again and we have progress...a new error:

配置:错误:找不到OpenSSL的

configure: error: Cannot find OpenSSL's

从我们的最后一次尝试中吸取教训,让我们尝试:

Learning from our last foray let’s try:

sudo apt-get install openssl-dev

sudo apt-get install open-ssl-dev

不,好的,我们来进行搜索:

Nope, Okay let’s do a search for this:

apt-cache search openssl 

哇,好多包.让我们缩小一点:

Wow, that’s quite a few packages. Let’s narrow it down a bit:

apt-cache search openssl | grep php

这给了我们一个较小的列表,但是所有人都在前面使用了php5,而我们正在做一个php7(从头开始构建phpng Next Generation);这些软件包中的任何一个都能工作吗?进入我们的解决方案的互连网:

Well that gives us a smaller list, but all have php5 in the front and we are doing a php7 (phpng Next Generation build from scratch); will any of these packages work? Off to the interwebs for our solution:

https://serverfault.com/questions/415458/php-error -cannot-find-openssls-evp-h

sudo apt-get install libcurl4-openssl-dev pkg-config

让我们看看是否使./configure感到高兴(不,但是进步了...一个新错误):

Let’s see if that made ./configure happy (nope, but progress...a new error):

配置:错误:请重新安装BZip2发行版

configure: error: Please reinstall the BZip2 distribution

再次搜索网络会导致我们:

Searching the web again leads us to:

http://zgadzaj .com/how-to-install-php-53-and-52-together-on-ubuntu-1204

告诉我们要这样做:

sudo apt-get install libbz2-dev

再一次,我们向./configure神祈祷...

Once again we send a prayer to the ./configure god and...

如果配置失败,请尝试--with-vpx-dir = 配置:错误:找不到jpeglib.h.

If configure fails try --with-vpx-dir= configure: error: jpeglib.h not found.

到网络!!

发现了此内容: http://www.omniweb.com/wordpress/?p= 1040

sudo apt-get install libjpeg-dev 

再次尝试并进行调查:

Try ./configure again and SURVEY SAYS:

配置:错误:未找到png.h.

configure: error: png.h not found.

在与上述网站相同的网站上说:

From the same website as above it says to do this:

sudo apt-get install libpng-dev

再次尝试和调查说:

Try ./configure AGAIN and SURVEY SAYS:

找不到配置错误xpm.h

configure error xpm.h not found

我在黑暗中刺了一下,并用以下方法击中了目标:

I took a stab in the dark and hit the target with:

sudo apt-get install libxpm-dev

再一次向./configure神祈祷,答案是:

Once again praying to the ./configure god and the reply is:

配置:错误:未找到freetype-config.

configure: error: freetype-config not found.

万能的Google在这里将我们引向SO神:

The ALL KNOWING Google directs us to the SO god here:

配置php 5.3失败,并显示错误:找不到freetype.h(但已安装libfreetype6-dev)

sudo apt-get install libfreetype6-dev 

到目前为止,您可能已经认识到以下模式:

By now you have probably recognized the pattern of:

  1. 运行./configure

  1. run ./configure

在您喜欢的搜索引擎上搜索错误消息,或者直接搜索 在SO上.

Search the error message on your favorite search engine or directly on SO.

通过apt-get安装缺少的组件.

Install the missing component via apt-get.

GOTO 1.

所以从现在开始,我将仅显示错误以及apt-get命令或其他解决问题的命令:

So from here on I am just going to show the error and the apt-get command or other commands that resolve the issue:

配置:错误:无法找到gmp.h

configure: error: Unable to locate gmp.h

在ubuntu上构建php5.3.8,出现错误:配置:错误:无法找到gmp.h

sudo apt-get install libgmp-dev  
sudo apt-get install libgmp3-dev
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

配置:错误:找不到mcrypt.h.请重新安装libmcrypt.

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

sudo apt-get install libmcrypt-dev

配置:错误:请重新安装mysql发行版

configure: error: Please reinstall the mysql distribution

http://www.spiration.co.uk/post/1332/install%20PDO_MYSQL%20-%20mysql_config%20and%20header%20files%20problem

sudo apt-get install libmysqlclient15-dev  

配置:错误:找不到pspell

configure: error: Cannot find pspell

sudo apt-get install libpspell-dev

配置:错误:在/usr/下的任何位置都找不到recode.h usr/local/usr/opt.

configure: error: Can not find recode.h anywhere under /usr / usr/local /usr /opt.

sudo apt-get install librecode-dev

配置:警告:无法识别的选项:--with-t1lib

configure: WARNING: unrecognized options: --with-t1lib

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=658248

无解.似乎是回归错误.解决方法是从配置选项中删除--with-t1lib.我认为这可能仅适用于Windows版本,但我不确定.

No solution. Appears to be a regression bug. Workaround is to remove the --with-t1lib from the configuration options. I think this may apply to Windows builds only, but I’m not certain.

配置:警告:无法识别的选项:--with-my-sql

configure: WARNING: unrecognized options: --with-my-sql

无解.解决方法是从配置选项中删除--with-mysql开关.由于我们包括了pdo-mysql,所以这可能不是问题.

No solution. Work around is to remove the --with-mysql switch from the configuration options. Since we are including the pdo-mysql this is probably not an issue anyway.

最后,我们开始使用此命令实际构建PHP7(我建议您现在自己喝杯咖啡,因为这需要一些时间):

FINALLY We get to actually build PHP7 with this command (I suggest you make yourself a cup of coffee now as this takes some time) :

make

使用命令sudo make install实际安装我们的php构建:

Use the command sudo make install to actually install our php build:

sudo make install 

要检查一切是否正常,我们是否有正确的版本,请在终端中执行以下操作:

To check if all is well and we have the right version execute this in the terminal:

cd $HOME/tmp/usr/bin
./php -v

PHP 7.0.0-dev(CLI)(内置:2015年6月22日18:11:13) 版权所有(c)1997-2015 The PHP Group Zend Engine v3.0.0-dev, 版权所有(c)1998-2015 Zend Technologies

PHP 7.0.0-dev (cli) (built: Jun 22 2015 18:11:13) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies

这篇关于如何在Ubuntu上安装PHP 7(下一代PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆