环境:CentOS-6.7-x86_64-bin-DVD1.iso
其他依赖包的安装,这里省略了,得承认这个过程也是件麻烦的事情。
来吧,直奔主题:
tar -zxvf php-7.1.5.tar.gz
cd php-7.1.5
./configure \
--prefix=/usr/local/php-7.1.5 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/usr/local/php-7.1.5/etc \
--with-config-file-scan-dir=/usr/local/php-7.1.5/etc/php.d \
--with-mcrypt=/usr/local/libmcrypt \
--with-png-dir=/usr/local/libpng \
--with-jpeg-dir \
--with-freetype-dir \
--with-bz2 \
--with-curl \
--with-gd \
--with-mhash \
--with-openssl \
--with-zlib \
--with-gettext \
--with-xmlrpc \
--enable-mysqlnd \
--enable-bcmath \
--enable-fpm \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-zip
make
make test
make install
cp php.ini-production /usr/local/php-7.1.5/etc/php.ini
相比我本地旧版 PHP-5.3 还缺少:
ereg
libevent
mhash
说明:
--with-mysql // 已被弃用
mysqlnd // PHP5.3 以后 PHP 内置的 MYSQL 客服端驱动,以往使用的是 MYSQL 提供的驱动 libmysql
ereg // PHP5.3 开始不建议使用,PHP7 废除
mhash // PHP5.3 开始,mhash 是通过 hash 扩展来模拟的
安装 memcached 扩展
http://libmemcached.org/libMemcached.html
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure -prefix=/usr/local/libmemcached --with-memcached
make && make install
http://pecl.php.net/package/memcached
tar -zxvf memcached-3.0.3.tgz
cd memcached-3.0.3
/usr/local/php-7.1.5/bin/phpize
./configure --with-libmemcached-dir=/usr/local/libmemcached --with-php-config=/usr/local/php-7.1.5/bin/php-config
make && make install
/usr/local/php-7.1.5/lib/php/extensions/no-debug-zts-20160303/memcached.so
vi /usr/local/php-7.1.5/etc/php.ini
extension=/usr/local/php-7.1.5/lib/php/extensions/no-debug-zts-20160303/memcached.so
/usr/local/apache/bin/apachectl -k restart
安装 redis 扩展
http://pecl.php.net/package/redis
tar -zxvf redis-3.1.2.tgz
cd redis-3.1.2
/usr/local/php-7.1.5/bin/phpize
./configure --with-php-config=/usr/local/php-7.1.5/bin/php-config
make && make install
/usr/local/php-7.1.5/lib/php/extensions/no-debug-zts-20160303/redis.so
vi /usr/local/php-7.1.5/etc/php.ini
extension=/usr/local/php-7.1.5/lib/php/extensions/no-debug-zts-20160303/redis.so
/usr/local/apache/bin/apachectl -k restart
如果你也使用的 Apache:
vi /usr/local/apache/conf/httpd.conf
#LoadModule php5_module modules/libphp5.so
LoadModule php7_module modules/libphp7.so
/usr/local/apache/bin/apachectl -k restart