麦都-平台开发组

linux服务器PHP升级到7

写作时间:2018-05-08

PHP安装

本文以php7.0.30为例,下载地址:http://cn2.php.net/get/php-7.0.30.tar.gz/from/this/mirror

tar -zxvf php-7.0.30.tar.gz

cd php-7.0.30

安装依赖包,有安装就不需要
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

编译安装PHP

./configure  --prefix=/alidata/server/php-7.0.30 --with-openssl --with-config-file-path=/alidata/server/php-7.0.30/etc --with-mysqli --with-pdo-mysql --with-gd --with-iconv=/usr/local/libiconv --with-zlib --enable-zip --enable-inline-optimization --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --with-pcre-regex --with-png-dir --enable-fileinfo

make && make install
软链接
ln -s /alidata/service/php-7.0.30 /alidata/service/php

配置php-fpm 

cp php.ini-production /alidata/service/php/etc/php.ini
cp /alidata/service/php/etc/php-fpm.conf.default /alidata/service/php/etc/php-fpm.conf
cp /alidata/service/php/etc/php-fpm.d/www.conf.default /alidata/service/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

启动php-fpm

/etc/init.d/php-fpm start


PHP扩展安装

以 memcache  为例

wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

unzip pecl-memcache-php7.zip
cd pecl-memcache-php7
/alidata/service/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
redis
wget http://pecl.php.net/get/redis-3.1.2.tgz



修改 /alidata/service/php/etc/php.ini 

extension_dir = "/alidata/server/php-7.0.30/lib/php/extensions/no-debug-non-zts-20151012/"
.....
extension=memcache.so