Compile PHP7 under CentOS
PHP 7 has also been released for a long time. Up to now, PHP 7 is PHP 7.0.1. this version follows the latest official version for Compilation. if there are not many changes, it is also applicable to PHP 7.0.1 and later versions.
This compilation is completed under Baidu Cloud (CentOS 6.
Compile PHP
We need to deal with some dependencies before compilation.
yum install gcc make libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel pcre-devel libcurl-devel libmcrypt libmcrypt-devel
Add a www user to run PHP
groupadd wwwuseradd-s /sbin/nologin -g www www
Download the PHP installation package and decompress it.
wget http://cn2.php.net/distributions/php-7.0.1.tar.gz && tar -zxvf php-7.0.1.tar.gz && cd php-7.0.1
Compile
./configure --prefix=/opt/software/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcachemake && make install
After the above code is executed, PHP will be compiled to the/opt/software/php directory.
Copy php. ini
cp php.ini-production /opt/software/php/etc/php.ini
And make a copy of the php-fpm.conf.default.
cd /opt/software/php/etccp php-fpm.conf.default php-fpm.conf
Then I made a copy of www. conf. default in the php-fpm.d.
cd php-fpm.d && cp www.conf.default www.conf
Then check to see if there are any errors. if not, start php-fpm.
/opt/software/php/sbin/php-fpm -t
If successfully is displayed
/opt/software/php/sbin/php-fpm