配置php_opcache扩展使php7运行更加快速

博客地址:让PHP7达到最高性能的几个Tips

  • 安装opcache

yum --enablerepo=remi-php72 install php-opcache

  • 找到opcache文件

find / -name 'opcache.so'

  • 修改opcache的配置文件

vi /etc/php.d/10-opcache.ini

  • 修改文件位置

zend_extension=/usr/lib64/php/modules/opcache.so

  • 修改缓存文件时长

opcache.revalidate_freq=600

  • 找到PHP-fpm主进程

ps -ef | grep 'php-fpm’

kill -USR2 进程ID 平滑重启

  • 后续更新代码需要清空缓存,当前服务器hosts加上

127.0.0.1 daka.01lb.com.cn

  • 项目根目录文件加上 opcache.php
  • 发布代码后请求文件使缓存生效

curl http://daka.01lb.com.cn/opcache.php

你可能感兴趣的:(配置php_opcache扩展使php7运行更加快速)