lnmp1.5下开启opcache的开启和关闭

服务器环境CentOS7.2 + lnmp1.5,由于安装的是PHP 7.1,根据各种测试情况来看,开启opcache会提升不少性能,那咱得上啊。

开启opcache

cd lnmp1.5
./addons.sh
+-----------------------------------------------------------------------+
|            Addons script for LNMP V1.4, Written by Licess             |
+-----------------------------------------------------------------------+
|    A tool to Install cache,optimizer,accelerator...addons for LNMP    |
+-----------------------------------------------------------------------+
|           For more information please visit https://lnmp.org          |
+-----------------------------------------------------------------------+
##### cache / optimizer / accelerator #####
1: eAccelerator
2: XCache
3: Memcached
4: opcache
5: Redis
6: apcu
##### Image Processing #####
7: imageMagick
##### encryption/decryption utility for PHP #####
8: ionCube Loader
exit: Exit current script
#####################################################
Enter your choice (1, 2, 3, 4, 5, 6, 7, 8 or exit): 4
Install Opcache will auto uninstall eAccelerator if exists...
====== Installing zend opcache ======
Press any key to start...or Press Ctrl+c to cancel

然后你按任意键就安装好了,在此感谢lnmp脚本为我们带来的便利。

关闭opcache:

在调试的时候,会发现刚修改的php代码好像并没有生效,清空框架缓存啥的也没效果,但是稍微过一会儿就生效了,推测是opcache的效果导致,所以我们在上线前可以先关闭它。

先运行一下phpinfo(),搜索opcache看一下你的配置文件目录在哪,如下图:

phpinfo查找配置文件

这个配置文件默认配置概是这样的:

[Zend Opcache]
zend_extension="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

把这里面的每一行前面加上;来注释它,然后重启php-fpmnginx即可。

lnmp1.5下开启opcache的开启和关闭

原文链接:https://beltxman.com/2138.html,若无特殊说明本站内容为 行星带 原创,未经同意禁止转载。

lnmp1.5下开启opcache的开启和关闭”上有 4 条评论;

    1. 如文章中所说的,这里用的是lnmp1.5内置的,如果要在其他的linux环境下开启opcache,可以参考官方文档:http://php.net/manual/zh/opcache.installation.php,来安装开启

  1. 博主你好,opcache安装完毕就可以了吗?wordpress后台需要安装相应的插件吗?

评论已关闭。

Scroll to top