Errors encountered in source code compilation of PHP7 and Solutions

origin

Recently, PHP7 was installed in the win10 subsystem, and encountered various problems. Google's record solution.

Download source code

There are three ways to get PHP source code:

  1. Github download, https://github.com/php/php-src.git
  2. git.php.net Download
  3. Compressed package download http://php.net/downloads.php

Choose Github to download:

//Update dependency
sudo apt-get update  
sudo apt-get install build-essential  
//Installation dependency
sudo apt-get install -y autoconf libtool re2c libxml2-dev openssl libcurl4-openssl-dev  libbz2-dev libjpeg-dev libpng12-dev libfreetype6-dev libldap2-dev  libmysqlclient-dev libxslt1-dev libxt-dev libpcre3-dev libxpm-dev libt1-dev libgmp-dev libpspell-dev librecode-dev libreadline6-dev bison libtidy-dev  
//Download source code
wget https://github.com/php/php-src/archive/php-7.0.20.tar.gz
//decompression
tar -xzvf php-7.0.20.tar.gz
cd php-7.0.20
//Generate the configure file
./autoconf
//Check configuration
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/run/mysql/mysql.sock --enable-opcache --enable-ctype --enable-fpm --enable-tokenizer --enable-fileinfo --enable-pdo --enable-sockets --enable-exif --enable-soap --enable-ftp --enable-wddx --enable-pcntl --enable-soap --enable-bcmath --enable-mbstring --enable-dba  --enable-gd-jis-conv --enable-zip --enable-calendar --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-mysqli --with-pdo-mysql --with-pdo-sqlite --with-iconv --with-gmp --with-pspell --with-gettext --with-xmlrpc --with-openssl --with-mhash --with-xsl --with-curl --with-pcre-regex --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr  --with-gettext=/usr --with-zlib=/usr --with-bz2=/usr --with-recode=/usr --with-ldap --with-pear --with-readline
//Compile and install
make && make install

-The v parameter indicates the output version number. If you see the output php version information after the command is executed, the compilation is successful.

Common mistakes

Mistake 1

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

Solve

apt-get install libxml2-dev

Error two

/usr/bin/mysql_config: No such file or directory

Solve:

apt-get install mysql-server mysql-client libmysqlclient-dev

Error three

Warning: Declaration of PEAR_Installer::download() should be compatible with & PEAR_Downloader::download($params) in phar:///root/php7/php-src/pear/install-pear-nozlib.phar/PEAR/Installer.php on line 43

Warning: Declaration of PEAR_PackageFile_Parser_v2::parse() should be compatible with PEAR_XMLParser::parse($data) in phar:///root/php7/php-src/pear/install-pear-nozlib.phar/PEAR/PackageFile/Parser/v2.php on line 113
[PEAR] Archive_Tar - installed: 1.3.13
[PEAR] Console_Getopt - installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4

Warning: Declaration of PEAR_Task_Replace::init() should be compatible with PEAR_Task_Common::init($xml, $fileAttributes, $lastVersion) in phar:///root/php7/php-src/pear/install-pear-nozlib.phar/PEAR/Task/Replace.php on line 31
[PEAR] XML_Util - installed: 1.2.3

Warning: Declaration of PEAR_Task_Windowseol::init() should be compatible with PEAR_Task_Common::init($xml, $fileAttributes, $lastVersion) in phar:///root/php7/php-src/pear/install-pear-nozlib.phar/PEAR/Task/Windowseol.php on line 76

Warning: Declaration of PEAR_Task_Unixeol::init() should be compatible with PEAR_Task_Common::init($xml, $fileAttributes, $lastVersion) in phar:///root/php7/php-src/pear/install-pear-nozlib.phar/PEAR/Task/Unixeol.php on line 76
[PEAR] PEAR - installed: 1.9.5
Wrote PEAR system config file at: /root/php7/usr/etc/pear.conf

Solve:

You may want to add: /root/php7/usr/lib/php to your php.ini include_path
/root/php7/php-src/build/shtool install -c ext/phar/phar.phar /root/php7/usr/bin

Error four

configure: WARNING: unrecognized options: --with-mysql

Solve:

Use - with PDO MySQL instead

Error five

checking for bison version... invalid
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).
checking for re2c... no
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!

Solve

apt-get install bison

Error six

configure: error: Cannot find OpenSSL's

Solve

apt-get install libssl-dev

Error seven

configure: error: Cannot find OpenSSL's libraries

Solve

apt-get install libssl-dev

error

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

Solve

apt-get install libbz2-dev

error

configure: error: Please reinstall the libcurl distribution –
easy.h should be in /include/curl/

Solve

apt-get install libcurl4-openssl-dev

error

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

Solve

apt-get install libjpeg-dev

error

configure: error: png.h not found.

Solve

apt-get install libpng12-dev

error

configure: error: freetype-config not found.

Solve

apt-get install libfreetype6-dev

error

//The mcrpyt extension has been discarded in PHP 7 and above. Please use openssl instead
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Solve

apt-get install libmcrypt-dev

error

configure: error: Cannot find pspell

Solve

apt-get install libpspell-dev

error

PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.

Solve

pear install pear/PHP_Archive

error

checking for recode support... yes
configure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.

Solve

apt-get install librecode-dev

Tags: PHP MySQL OpenSSL github

Posted on Wed, 25 Mar 2020 12:17:04 -0400 by acidglitter