Taken from Stackoverflow, credits to @ryannerd.
User contributed content licensed under cc-wiki with attribution required.
Guide to install PHP7
1 2 3 4 5 6 7 |
./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:
1 2 3 |
./buildconf |
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:
1 2 3 4 |
sudo apt-get purge make sudo apt-get install make |
Next problem when I tried ./buildconf again it complained that I did not have autoconfig. Here’s the solution to that:
1 2 3 |
sudo apt-get install autoconf |
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:
1 2 3 |
sudo apt-get install bison |
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:
1 2 3 |
sudo apt-get install libxml2 |
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:
1 2 3 |
sudo apt-get purge libxml2 sudo apt-get install libxml2 |
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:
1 2 3 |
sudo apt-get install libxml2-dev |
./configure again and we have progress…a new error:
configure: error: Cannot find OpenSSL’s
Learning from our last foray let’s try:
1 2 3 |
sudo apt-get install openssl-dev |
or
1 2 3 |
sudo apt-get install open-ssl-dev |
Nope, Okay let’s do a search for this:
1 2 3 |
apt-cache search openssl |
Wow, that’s quite a few packages. Let’s narrow it down a bit:
1 2 3 |
apt-cache search openssl | grep php |
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
1 2 3 |
sudo apt-get install libcurl4-openssl-dev pkg-config |
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:
1 2 3 |
sudo apt-get install libbz2-dev |
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!!!
1 2 3 |
sudo apt-get install libjpeg-dev |
Try ./configure PHP7 again and SURVEY SAYS:
configure: error: png.h not found.
From the same website as above it says to do this:
1 2 3 |
sudo apt-get install libpng-dev |
Try ./configure AGAIN and:
configure error xpm.h not found
I took a stab in the dark and hit the target with:
1 2 3 |
sudo apt-get install libxpm-dev |
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)
1 2 3 |
sudo apt-get install libfreetype6-dev |
By now you have probably recognized the pattern of:
- run ./configure
- Search the error message on your favorite search engine or directly on SO.
- Install the missing component via apt-get.
- 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
1 2 3 4 5 |
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 |
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
1 2 3 |
sudo apt-get install libmcrypt-dev |
configure: error: Please reinstall the mysql distribution
1 2 3 |
sudo apt-get install libmysqlclient15-dev |
configure: error: Cannot find pspell
1 2 3 |
sudo apt-get install libpspell-dev |
configure: error: Can not find recode.h anywhere under /usr / usr/local /usr /opt.
1 2 3 |
sudo apt-get install librecode-dev |
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) :
1 2 3 |
make |
Use the command sudo make install to actually install our php build:
1 2 3 |
sudo make install |
To check if all is well and we have the right version execute this in the terminal:
1 2 3 4 |
cd $HOME/tmp/usr/bin ./php -v |
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
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
Hi!
Try the following before:
apt-get install libtool-ltdl
or if it doesnt work tryapt-get install libtool-ltdl-devel
Merry Christmas Buddy!