centos php7编译安装Redis,obcache扩展

3 篇文章 0 订阅

需求

目前需要安装php的扩展

  1. redis
  2. obcache

安装 redis

下载

wget https://pecl.php.net/get/redis-5.0.2.tgz

解压

tar -zxvf redis-5.0.2.tgz

进入扩展目录执行 phpize

/usr/local/services/7.1.8/bin/phpize

报错

Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决:

yum install autoconf

执行configure

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

构建

make && make install

完毕

Installing shared extensions: /usr/local/services/php@7.1/7.1.8/lib/php/extensions/no-debug-zts-20160303/


配置

修改 php.ini 文件
extension=redis.so

安装 opcache

补充: 傻了,PHP7自带opchache扩展,不用编译安装了,php5 才需要。

下载

wget https://pecl.php.net/get/zendopcache-7.0.5.tgz

解压

tar -zxvf zendopcache-7.0.5.tgz

安装

第一步
/usr/local/services/7.1.8/bin/phpize
第二步
./configure --with-php-config=/usr/local/services/7.1.8/bin/php-config
第三步
make -j 4 && make install

错误

报错1
   zend_uint               key_length);
   ^
/usr/local/src/php/zendopcache-7.0.5/zend_accelerator_hash.h:87:3: error: unknown type name ‘zend_uint’
   zend_uint               key_length);
   ^
/usr/local/src/php/zendopcache-7.0.5/ZendAccelerator.c:39:35: fatal error: TSRM/tsrm_virtual_cwd.h: No such file or directory
 #include "TSRM/tsrm_virtual_cwd.h"

原因: PHP 版本问题,编译安装官网只有PHP5的扩展版本。


配置

修改 php.ini 文件

zend_extension=opcache.so
[opcach]
; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1

; The OPcache shared memory storage size.
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=10000

清理opcache缓存工具

当然是 cachetool

工具参考: CacheTool

安装

curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar
chmod +x cachetool.phar

使用

You can connect to a fastcgi server using an IP address

查看状态
php cachetool.phar opcache:status --fcgi=127.0.0.1:9000
清理
php cachetool.phar opcache:reset --fcgi=127.0.0.1:9000

Using the CLI

查看状态
php cachetool.phar opcache:status --cli
清理
php cachetool.phar opcache:reset --cli

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值