How to install PHP7 on Ubuntu or Debian

php7

Taken from Stackoverflow, credits to @ryannerd.

User contributed content licensed under cc-wiki with attribution required.

Guide to install PHP7

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

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

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

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

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

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!

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

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

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

Should be an easy fix right? Just run:

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

libxml2 is already the newest version.

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

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

How to fix error with xml2-config not found when installing PHP from sources?

Aparently we need the development version of this library:

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

configure: error: Cannot find OpenSSL’s

Learning from our last foray let’s try:

or

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

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

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:

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

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

configure: error: Please reinstall the BZip2 distribution

Can be solved using:

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

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

TO THE INTERWEBS!!!

Try ./configure PHP7 again and SURVEY SAYS:

configure: error: png.h not found.

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

Try ./configure AGAIN and:

configure error xpm.h not found

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

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

configure: error: freetype-config not found.

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

Configure php 5.3 fail with error : freetype.h not found (but libfreetype6-dev is installed)

By now you have probably recognized the pattern of:

  1. run ./configure
  2. Search the error message on your favorite search engine or directly on SO.
  3. Install the missing component via apt-get.
  4. GOTO 1.

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

configure: error: Unable to locate gmp.h

build php5.3.8 on ubuntu , get error: configure: error: Unable to locate gmp.h

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

configure: error: Please reinstall the mysql distribution

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

configure: error: Cannot find pspell

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

configure: WARNING: unrecognized options: –with-t1lib

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

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.

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

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.

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) :

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

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

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

2 thoughts on “How to install PHP7 on Ubuntu or Debian

  1. add –enable-zip or any other extensions

    IT will assertion errors:
    configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no

    help me

Leave a Reply

Your email address will not be published. Required fields are marked *