CenOS7环境安装PHP7扩展(持续更新)

相关路径

php路径: /usr/local/php7/
phpize路径: /usr/local/php7/bin/phpize
php-config路径: /usr/local/php7/bin/php-config
php.ini路径: /usr/local/php7/lib/php.ini
具体路径视安装时的配置而定

xdebug

https://xdebug.org/download.php

cd /usr/src
wget https://xdebug.org/files/xdebug-2.5.5.tgz
tar -zxvf xdebug-2.5.5.tgz
cd xdebug-2.5.5
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make install
# 修改php.ini
vim /usr/local/php7/lib/php.ini
# 添加如下配置
[xdebug]
zend_extension=xdebug.so;
xdebug.remote_enable=on;
xdebug.remote_handler=dbgp;
xdebug.remote_host=localhost;
xdebug.remote_port=9100;
xdebug.idekey=PHPSTORM;

# 重启php-fpm
service php-fpm restart

php --version
# 看到有with Xdebug v2.5.5就是成功了

redis

下载支持php7的redis扩展并编译安装

cd /usr/src
git clone https://github.com/phpredis/phpredis.git
cd phpredis
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make install

# 修改php.ini
vim /usr/local/php7/lib/php.ini
# 在END前加上
extension=redis.so;

# 重启php-fpm
service php-fpm restart

swoole

git clone https://github.com/swoole/swoole-src.git
cd swoole-src
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make 
make install

#修改php.ini
vim /usr/local/php7/lib/php.ini
#在END前加上
extension=swoole.so;


# 重启php-fpm
service php-fpm restart

# 查看swoole版本
php -r 'echo SWOOLE_VERSION;'

memcached

cd /usr/src
git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
git checkout php7
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make && make install

#修改php.ini
vim /usr/local/php7/lib/php.ini
#在END前加上
extension=memcached.so;

# 重启php-fpm
service php-fpm restart

gearman

yum install -y gearman-server gearmand
yum install -y php-devel php-pear httpd-devel libgearman libgearman-devel
cd /usr/src
git clone https://github.com/wcgallego/pecl-gearman.git
cd pecl-gearman/
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make install

#修改php.ini
vim /usr/local/php7/lib/php.ini
#在END前加上
extension=gearman.so;

# 重启php-fpm
service php-fpm restart

#启动gearman
gearmand -d

mongoDB

#安装mongodb-php扩展
/usr/local/php7/bin/pecl install mongodb

#编辑php.ini文件
vim /usr/local/php7/lib/php.ini

#在最下面的END前加上
extension=mongodb.so;

service php-fpm restart

如果pecl安装mongodb扩展失败,可以手动下载mongdo扩展安装包

cd /usr/src/
wget https://pecl.php.net/get/mongodb-1.2.9.tgz
tar zxvf mongodb-1.2.9.tgz
cd mongodb-1.2.9
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make install

phalcon7

sudo yum install php-devel php-mysql gcc libtool pcre-devel
cd /usr/src
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

vim /usr/local/php7/lib/php.ini
extension=phalcon.so;
service php-fpm restart

yaf

/usr/local/php7/bin/pecl install yaf

vim /usr/local/php7/lib/php.ini

#在最下面的END前加上
extension=yaf.so;

service php-fpm restart

grpc

/usr/local/php7/bin/pecl install grpc

vim /usr/local/php7/lib/php.ini

#在最下面的END前加上
extension=grpc.so;

service php-fpm restart
添加新评论