首页 > 代码库 > 编译安装php7

编译安装php7

#! /bin/bash
##编译安装 php7
cd /root/soft || mkdir /root/soft && cd /root/soft 
wget http://cn2.php.net/distributions/php-7.0.12.tar.gz

tar -zxvf php-7.0.12.tar.gz
cd  php-7.0.12
./configure --prefix=/usr/local/php7  --sysconfdir=/usr/local/php7/etc  --with-config-file-path=/usr/local/php7/etc   --with-config-file-scan-dir=/usr/local/php7/etc/php.d  --enable-fpm  --enable-mbstring --enable-zip --enable-mysqlnd --with-iconv --with-zlib  --enable-xml  --with-curl   --with-gd  --with-openssl --with-mhash  --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts 

make clear
make && make install

mkdir /usr/local/php7/etc/php.d -p


cd /root/soft/php-7.0.12/sapi/fpm
cp init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
chkconfig --add php7-fpm
chkconfig php7-fpm on
cp php-fpm.conf /usr/local/php7/etc/php-fpm.conf
cp www.conf   /usr/local/php7/etc/php-fpm.d/www.conf
cd /root/soft/php-7.0.12
cp php.ini-production /usr/local/php7/etc/php.ini





cat >/usr/local/php7/etc/php.d/10-opcache.ini <<EOFF
zend_extension=opcache.so

opcache.enable=1

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.blacklist_filename=/etc/php.d/opcache*.blacklist
EOFF



##redis 扩展
yum install unzip -y 
cd /root/soft
wget -c https://github.com/phpredis/phpredis/archive/php7.zip
unzip php7.zip 
cd phpredis-php7/
/usr/local/php7/bin/phpize 
./configure  --with-php-config=/usr/local/php7/bin/php-config 
make
make install
echo "extension=redis.so" >> /usr/local/php7/etc/php.d/20.redis.ini

#######igbinary7扩展
cd /root/soft
wget https://github.com/igbinary/igbinary7/archive/master.zip
cd igbinary7-master
/usr/local/php7/bin/phpize
./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/usr/local/php7/bin/php-config
echo "extension=igbinary.so" >> /usr/local/php7/etc/php.d/20.igbinary.ini
echo "session.serialize_handler=igbinary" >> /usr/local/php7/etc/php.d/20.igbinary.ini



##memcache扩展
cd /root/soft
yum install -y libmemcached10-devel-1.0.16-1.ius.centos6.x86_64 libmemcached10-1.0.16-1.ius.centos6.x86_64
wget https://codeload.github.com/php-memcached-dev/php-memcached/zip/php7
unzip php7
cd php-memcached-php7/
/usr/local/php7/bin/phpize
./configure  --with-php-config=/usr/local/php7/bin/php-config --enable-memcached-igbinary
make
make install
echo "extension=memcached.so" >> /usr/local/php7/etc/php.d/20.memcached.ini

 

编译安装php7