温馨提示×

debian php中如何启用OPcache

PHP
小樊
95
2024-08-14 12:35:35
栏目: 编程语言
Debian服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

要在Debian上启用OPcache,您需要安装PHP的OPcache扩展并进行相关配置。以下是具体步骤:

  1. 安装OPcache扩展:
sudo apt-get update
sudo apt-get install php-opcache
  1. 打开php.ini文件并进行配置:
sudo nano /etc/php/7.4/apache2/php.ini

在php.ini文件中找到以下行并取消注释(删除前面的分号):

zend_extension=opcache.so

可以根据需要设置OPcache的其他配置项,如:

opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
  1. 重启Apache服务器以使更改生效:
sudo systemctl restart apache2

现在OPcache已经启用并配置完成,您可以在PHP脚本中使用OPcache来提高性能。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:Debian PHP如何使用缓存技术

0