Home  >  Article  >  php教程  >  opcache安装

opcache安装

WBOY
WBOYOriginal
2016-06-06 20:11:441707browse

前边已经测试过了opcache提升的性能,下边说说安装方法。 操作系统为centos opcache已经集成在了最新的的PHP5.5中,所以安装方法与PHP5.3、PHP5.4有所不同,下面会分别说明。 PHP5.5安装: 如果是第一次安装,可以在编译的时候加上enable-opcache参数 如果是

前边已经测试过了opcache提升的性能,下边说说安装方法。
操作系统为centos
opcache已经集成在了最新的的PHP5.5中,所以安装方法与PHP5.3、PHP5.4有所不同,下面会分别说明。

PHP5.5安装:
如果是第一次安装,可以在编译的时候加上–enable-opcache参数
如果是安装好的php,可以到源码的ext/opcahce目录下执行下列命令:

/opt/php55/bin/phpize
./configure --with-php-config=/opt/php55/bin/php-config
make -j4
make install

phpize 和php-config的路径需要根据自己的实际情况来修改,上述命令是我的配置

PHP5.3 & PHP5.4 安装:
如果是php5.3、5.4则没有集成到源码里,我们可以下载后编译

wget http://pecl.php.net/get/zendopcache-7.0.2.tgz
tar xzf zendopcache-7.0.2.tgz
cd zendopcache-7.0.2
/opt/php53/bin/phpize
./configure --with-php-config=/opt/php53/bin/php-config
make -j4
make install

安装完成后opcache.so会被安装到/opt/php53/lib/php/extensions/no-debug-non-zts-20090626目录下
我们需要在php.ini中添加下列配置

[Zend Opcache]
Zend_extension= /opt/php53/lib/php/extensions/no-debug-non-zts-20090626/opcache.so
Opcache.memory_consumption=64
Opcache.interned_strings_buffer=8
Opcache.max_accelerated_files=4000
Opcache.force_restart_timeout=180
Opcache.revalidate_freq=60
Opcache.fast_shutdown=1
Opcache.enable_cli=1

配置完成后可以通过php -i|grep opchche查看是否安装成功
成功后需要重启php-fpm或apche使之生效

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn