First install some dependent software packages:
Yum install libmcrypt. x86_64 libpng. x86_64 libjpeg-turbo.x86_64 \
Libxml2.x86 _ 64 readline. x86_64 libxml2-devel.x86_64 openssl. x86_64 \
Openssl-devel.x86_64 libcurl-devel.x86_64 libjpeg-turbo-devel.x86_64 \
Libwebp-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 \
Libmcrypt-devel.x86_64 readline-devel.x86_64
Then, configure the PHP 7 compilation options correctly.
./Configure-C \
-- Prefix =/usr/local/php \
-- With-readline \
-- With-curl \
-- With-gd \
-- With-iconv \
-- With-gettext \
-- With-mcrypt \
-- With-mysqli \
-- With-openssl \
-- Enable-pcntl \
-- Enable-soap \
-- Enable-mbstring \
-- With-zlib \
-- Enable-fpm \
-- With-freetype-dir =/usr \
-- With-jpeg-dir =/usr \
-- With-webp-dir =/usr \
-- With-png-dir =/usr
Finally, execute the compilation Command:
# Use 2 cores to determine the CPU usage.
Make-j 2
Make install
After compilation, compile opcache separately. Although I think this should be compiled into the PHP interpreter,
However, currently, I only find the method used in extension mode.
Cd ext/opcode
/Usr/local/php/bin/phpize
./Configure -- with-php-config =/usr/local/php/bin/php-config
Make-j 2
Make install
Then edit the configuration file and add:
Zend_extension = opcache. so
=====
The following is the PHP 5 compilation script:
#! /Bin/bash
Yum-yq install libmcrypt. x86_64 libpng. x86_64 libjpeg-turbo.x86_64 \
Libxml2.x86 _ 64 readline. x86_64 libxml2-devel.x86_64 openssl. x86_64 \
Openssl-devel.x86_64 libcurl-devel.x86_64 libjpeg-turbo-devel.x86_64 \
Libwebp-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 \
Libmcrypt-devel.x86_64 readline-devel.x86_64 libtool-ltdl-devel.x86_64
./Configure-C \
-- Prefix =/usr/local/php-5.5.16 \
-- With-readline \
-- With-curl \
-- With-gd \
-- With-iconv \
-- With-gettext \
-- With-mcrypt \
-- With-mysqli \
-- With-pdo-mysql \
-- With-openssl \
-- Enable-pcntl \
-- Enable-soap \
-- Enable-mbstring \
-- With-zlib \
-- Enable-fpm \
-- With-freetype-dir =/usr \
-- With-jpeg-dir =/usr \
-- With-png-dir =/usr