美文网首页
Centos7 yum 安装 php7.1

Centos7 yum 安装 php7.1

作者: Devil1994 | 来源:发表于2017-09-20 18:07 被阅读0次

配置yum源

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装

# yum -y install php71w-devel php71w-fpm

查看php版本

# php -v
PHP 7.1.8 (cli) (built: Aug  9 2017 19:19:49) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

查看php拓展

# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
mongodb
openssl
pcntl
pcre
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
tokenizer
xml
zip
zlib

[Zend Modules]

启动php-fpm

# systemctl start php-fpm.service

pecl安装php拓展

1.安装pecl

# curl -o go-pear.php http://pear.php.net/go-pear.phar
# php go-pear.php
//查看pecl是否安装成功
#pecl -V
Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249
...
//解决办法
#vim /usr/bin/pecl
//找到下面这句
---------------------------------------------------------------------------------------------------------------------------------------------
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
---------------------------------------------------------------------------------------------------------------------------------------------
//去掉-n
# pecl -V
PEAR Version: 1.10.5
PHP Version: 7.1.8
Zend Engine Version: 3.1.0
Running on: Linux localhost.localdomain 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64

2.安装拓展(以mongodb为例)

# pecl install mongodb
//编译的时候很可能会报错
error:Cannot find OpenSSL's <evp.h>
//解决办法
yum -y install openssl-devel openssl pkgconfig

最后在php.ini中添加一句

extension=mongodb.so

phpize安装拓展

//下载压缩包,解压,进入解压目录
# phpize    //一定要在解压的目录下执行
# ./configure --with-php-config=php-config所在目录    //如果你有多个php版本
# make && make install 
//最后在php.ini加上一句extension=***.so

ok!

相关文章

网友评论

      本文标题:Centos7 yum 安装 php7.1

      本文链接:https://www.haomeiwen.com/subject/dfwosxtx.html