Centos7 yum 安装 php7.1

Devil1994 · · 2525 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

配置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

ok!

本文来自:简书

感谢作者:Devil1994

查看原文:Centos7 yum 安装 php7.1

2525 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet