Centos7 安装php7.2 和pecl,swoole

Centos7 yum源没有PHP7的安装包,贼不方便。。。

Step 1 :换源

yum install epel-release

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

不安装epel有可能会报错。

Step 2: 安装PHP7.2

yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

2019.04.12更:如果上边的提示找不到安装包,试试下边这个

yum install php72 php72-php-cli php72-php-common php72-php-devel php72-php-embedded php72-php-fpm php72-php-gd php72-php-mbstring php72-php-mysqlnd php72-php-opcache php72-php-pdo php72-php-xml

Step 3: 安装pecl

默认安装 php7.2 没有pecl

yum install php72w-devel
yum install php72w-pear

不能偷懒,少写72w,用php-pear
这里可能会报错:
错误:php72w-common conflicts with php-common-5.4.16-45.el7.x86_64

Step 4:安装 swoole

pecl install swoole

错误处理

  1. C++ preprocessor “/lib/cpp” fails sanity check
    没有c++库
yum install glibc-headers
yum install gcc-c++ 
  1. fatal error: openssl/ssl.h: No such file or directory
yum install openssl-devel
  1. #error “Enable http2 support, require nghttp2 library.”
wget https://github.com/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.bz2

tar -xjf nghttp2-1.34.0.tar.bz2

如果解压报错
bzip2:无法 exec: 没有那个文件或目录
执行

yum install -y bzip2

接着

cd nghttp2-1.34.0
./configure
make
make install
  1. fatal error: hiredis/hiredis.h: No such file or directory
wget https://github.com/redis/hiredis/archive/v0.14.0.tar.gz

 tar xzvf v0.14.0.tar.gz

cd hiredis-0.14.0/

make && make install

执行

vi ~/.bash_profile
[最后加上这句]export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

[退出来]
source ~/.bash_profile

不修改.bash_profile文件,扩展添加会报错

Step 5:修改配置

php.ini 中加入
extension=swoole.so

执行

php -m

如果有swoole 扩展就大功告成。

附加:

我在supervisor 中运行swoole程序,报错
PHP Startup: Unable to load dynamic library ‘swoole.so’ (tried: /usr/lib64/php/modules/swoole.so (libhiredis.so.0.14: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/swoole.so.so (/usr/lib64/php/modules/swoole.so.so: cannot open shared object file: No such file or directory))

困扰了我很久,然后找到解决办法

echo '/usr/local/lib' >>/etc/ld.so.conf 
ldconfig
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值