CentOS-6.7 編譯安裝 PHP-7.1.5

環境:CentOS-6.7-x86_64-bin-DVD1.isophp

其餘依賴包的安裝,這裏省略了,得認可這個過程也是件麻煩的事情。html

來吧,直奔主題:mysql

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:redis

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
相關文章
相關標籤/搜索