天天看点

php查看opcache是否开启,开启opcache

查看和分析当前的Opcache加速效果那?答案是可以使用下Github上开源的项目:https://github.com/rlerdorf/opcache-status

将下载下来的项目放入到当前的Web服务器根目录下,直接访问即可,先看效果:

**开启这个最好把xdebug关闭**,不然缓存效果测不出来!

php.ini配置:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20151012/opcache.so

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable_cli=1

opcache.enable=1

【没开启第一次测试】:

[[email protected] ~]# ab -n 100 -c 10 http://nb.tobosu.com/

**Time taken for tests: 129.596 seconds**

**Requests per second: 0.77 [#/sec] (mean)**

** 【没开启第二次测试】:**

[[email protected] ~]# ab -n 100 -c 10 http://nb.tobosu.com/

**Time taken for tests: 144.500 seconds**

**Requests per second: 0.69 [#/sec] (mean)**

【开启后第一次测试】:

[[email protected] ~]# ab -n 100 -c 10 http://nb.tobosu.com/

**Time taken for tests: 122.882 seconds**

**Requests per second: 0.81 [#/sec] (mean)**

【开启后第二次测试】:

[[email protected] ~]# ab -n 100 -c 10 http://nb.tobosu.com/

**Time taken for tests: 124.468 seconds**

**Requests per second: 0.80 [#/sec] (mean)**

清除缓存:opcache_reset();或者重启php-fpm