PHP7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP7相关的知识,希望对你有一定的参考价值。

一、安装http2并更新curl
1、http2:
wget https://github.com/nghttp2/nghttp2/releases/download/v1.32.0/nghttp2-1.32.0.tar.gz
tar -zxvf nghttp2-1.32.0.tar.gz
cd nghttp2-1.32.0
./configure
make
make install

更新动态库
vim /etc/ld.so.conf
添加/usr/local/lib
更新配置文件,执行ldconfig

2、更新curl
vim /etc/yum.repos.d/city-fan.repo
[cityfan]
name=cityfan

baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/

baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/
enabled=1
gpgcheck=0

然后更新libcurl或者curl

yum install epel-release
yum upgrade libcurl

测试curl对http2的支持

curl --http2 -I https://nghttp2.org/

二、安装Hiredis
wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz
tar -zxvf v0.13.3.tar.gz
cd hiredis-0.13.3/
make
make install
ldconfig

三、编译安装php
1、下载PHP7.1最新版本(wget http://cn.php.net/distributions/php-7.1.23.tar.gz)

2、配置安装到data目录(fpm-user=www)
PS:可能需要安装的依赖,根据运维要求可选择其他方式安装:yum install pcre pcre-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel recode-devel cyrus-sasl-devel.x86_64

报错处理:
collect2: error: ld returned 1 exit status

需卸载原有的openssl避免冲突

yum remove openssl openssl-dev

ssl安装为shared
./config -fPIC --prefix=/usr/local/openssl/ enable-shared

安装命令:
./configure --prefix=/data/php --with-config-file-path=/data/php/etc --with-config-file-scan-dir=/data/php/etc/conf.d --disable-cgi --enable-mysqlnd --enable-bcmath --with-pdo-mysql=mysqlnd --with-curl --with-pcre-regex --with-readline --with-recode --with-zlib --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-pdo-mysql --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-mbstring --enable-phar=shared --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --with-openssl-dir=/usr/local/ssl --with-openssl --with-mcrypt --with-iconv

编译
make
make test
make install

配置文件
cp php.ini-production /data/php/etc/php.ini
PATH=$PATH:/data/php/bin
vim /etc/profile
source /etc/profile

四、php扩展安装

1、pecl扩展
pecl channel-update pecl.php.net

#---redis
pecl install redis

cd /data/tmp

#---apcu
wget http://pecl.php.net/get/apcu-5.1.12.tgz
pecl install apcu-5.1.12.tgz

#---igbinary
wget http://pecl.php.net/get/igbinary-2.0.7.tgz
pecl install igbinary-2.0.7.tgz

#---memcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached
make && make install

wget http://pecl.php.net/get/memcached-3.0.4.tgz
pecl install memcached-3.0.4.tgz
#输入libmemcached的安装目录/usr/local/libmemcached

#---memcache
wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
unzip php7.zip
cd pecl-memcache-php7/
phpize
./configure --with-php-config=/data/php/bin/php-config
ake && make install

#rabbitmq & ampq
wget https://github.com/alanxz/rabbitmq-c/archive/v0.9.0.tar.gz
cd rabbitmq-c-0.9.0/
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rabbitmq-c ..
cmake --build . --target install
ln -s /usr/local/rabbitmq-c/lib64/librabbitmq.so.4.3.0 /usr/local/lib/librabbitmq.so

wget http://pecl.php.net/get/amqp-1.9.3.tgz
pecl install amqp-1.9.3.tgz
#路径输入/usr/local/rabbitmq-c

#清除缓存
pecl clear-cache

2、编译安装swoole
wget https://github.com/swoole/swoole-src/archive/v4.0.1.tar.gz
tar -zxvf v4.0.1.tar.gz
cd swoole-src-4.0.1/
phpize
./configure --with-php-config=/data/php/bin/php-config --enable-async-redis --enable-mysqlnd --enable-openssl --enable-http2
make
make install

#添加可执行权限
cd /data/php/lib/php/extensions/no-debug-non-zts-20160303/
chmod +x *.so

3、打开php.ini文件开启扩展
extension=redis.so
extension=apcu.so
#extension=bcmath.so
extension=amqp.so
extension=swoole.so
extension=memcached.so
extension=memcache.so
extension=igbinary.so

以上是关于PHP7的主要内容,如果未能解决你的问题,请参考以下文章