centos7 php如何编译安装sockets扩展

1.进入到php源码下载后解压的目录,再进入ext/sockets目录,在该目录下执行下面的命令

/usr/local/php/bin/phpize

如果出现 "Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment vari"这个错误,执行以下命令,再重新运行phpize

yum install m4
yum install autoconf

2.使用 ./configure 进行配置

./configure --with-php-config=/usr/local/php/bin/php-config

3.安装

make && make install

如果没有错误,会输出下面这个结果:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
Installing header files:          /usr/local/php/include/php/

说明sockets扩展经过编译后,安装在了/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/这个目录下
4.修改php.ini,把sockets扩展加进去

vim /usr/local/php/etc/php.ini

把下面这两行加到php.ini里面

extension_dir = /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
extension = sockets.so

5.重启一下php,这样扩展就安装好了

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

6.查看扩展是否安装成功,如果看到sockets就说明安装成功了

php -m
志博

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: