Compile PHP7 in CentOS

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.