Centos7 安装php7.2 和pecl,swoole

编程知识 行业动态 更新时间:2024-06-13 00:22:54

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

Step 1 :换源

yum install epel-release

rpm -ivh http://rpms.famillecollet/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/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/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

更多推荐

Centos7 安装php7.2 和pecl,swoole

本文发布于:2023-04-03 12:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/008a1a5c5bcab1fbb90cb7f907d6e7fb.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:swoole   pecl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!