PHP-7.1.6 source compilation and installation

Posted by cdinca on Tue, 05 May 2020 20:06:12 +0200

Explain

php5 and php7 can be installed in an apache server at the same time, but only one of them can run. The other needs to comment out the corresponding LoadModule in the apache configuration file

1. Download and install

[root@dl-001 src]#  wget http://cn2.php.net/distributions/php-7.1.6.tar.gz
[root@dl-001 src]#  tar -zxvf php-7.1.6.tar.gz
[root@dl-001 src]#  cd php-7.1.6

2. Initialization

[root@dl-001 php-7.1.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif 

Note: the – with MySQL parameter has been removed in php7

Error 1

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

Description: the xml2 library is missing.

terms of settlement:

[root@dl-001 php-5.6.30]# yum list |grep libxml2 / / find the related library installation package
[root@dl-001 php-5.6.30]# Yum install - y libxml2 devel / / install the library file

Error 2

configure: error: Cannot find OpenSSL's <evp.h>

Description: OpenSSL's is missing.

terms of settlement

[root@dl-001 php-5.6.30]# yum install -y openssl-devel

Error 3

configure: error: Please reinstall the BZip2 distribution

Note: reinstall BZip2.

terms of settlement

[root@dl-001 php-5.6.30]# yum install -y bzip2-devel

Error 4

configure: error: jpeglib.h not found.

Note: the jpeg library is missing.

terms of settlement

[root@dl-001 php-5.6.30]# yum install -y libjpeg-devel

Error 5

configure: error: png.h not found.

Description: the png library is missing.

terms of settlement

[root@dl-001 php-5.6.30]# yum install -y libpng-devel

Error 6

configure: error: freetype-config not found.

Description: the freetype library is missing.

terms of settlement

[root@dl-001 php-5.6.30]# yum install -y freetype-devel

Error 7

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

Description: the mcrypt library is missing.

terms of settlement

[root@dl-001 php-5.6.30]# yum install epel-release
[root@dl-001 php-5.6.30]# yum install -y libmcrypt-devel

3. Compile and install

[root@dl-001 php-7.1.6]# make / / compile
[root@dl-001 php-7.1.6]#  make install / / install

PHP Description:

View the php7 module generated by apache

[root@dl-001 src]# ls /usr/local/apache2.4/modules/libphp7.so

View the modules loaded by php7

[root@dl-001 src]#  /usr/local/php7/bin/php -m

There are two versions of php in the apache server. Close a version of php module by commenting out the corresponding lines in the apache configuration file

[root@dl-001 src]#  vim /usr/local/apache2.4/conf/httpd.conf

Comment before LoadModule line

Topics: PHP yum Apache MySQL