Home > Article > Backend Development > How to install php extension module on centos
How to install php extension module in centos: 1. Install pecl; 2. Install libevent-devel; 3. Execute the command [echo extension=libevent.so > /etc/php.d/libevent.ini] .
The operating environment of this article: centos7 system, php 7.3, thinkpad t480 computer.
In the centos system, we can generally use two methods to install extension modules. One method is the yum command, and the other method is phpize. Let’s introduce these two methods and take a look at them together.
1. yum command
If you used the yum command to install php before, congratulations. You can also use the same method to install php extensions. The specific steps are as follows:
Tip: Please install pecl before executing the following command. If you have not installed it yet, please install it as follows:
//打开对应安装版本目录 cd /usr/local/php/bin/ //curl下载 curl -o go-pear.php http://pear.php.net/go-pear.phar//安装 php go-pear.php
Okay, start the installation PHP extension:
1、yum install libevent-devel 2、pecl install channel://pecl.php.net/libevent-0.1.0 3、echo extension=libevent.so > /etc/php.d/libevent.ini
2. phpize
This method may be more cumbersome to operate, so be patient when installing. Let’s take a look at the specific installation steps:
//下载libevent扩展文件压缩包~# wget http://pecl.php.net/get/libevent-0.1.0.tgz //解压~# tar -zxvf libevent-0.1.0.tgz //进入源码目录~# cd libevent-0.1.0/ //运行phpize命令,写全phpize的路径~# /usr/local/php/bin/phpize //运行configure命令,配置时 要将php-config的路径附上~# ./configure --with-php-config=/usr/local/php/bin/php-config //运行make命令~# make //测试编译安装~# make test //正式编译安装~# sudo make install //修改php.ini,结尾加入:extension=libevent.so //重启对应的php-fpm
Recommended learning: php training
The above is the detailed content of How to install php extension module on centos. For more information, please follow other related articles on the PHP Chinese website!