centos php redhat,RHEL / CentOS 安装 OPcache 提升 PHP 效能

OPcache 在 PHP 5.5 (默认没有开启)开始内建在 PHP, 前身是 Zend Optimizer, PHP 5.2, 5.3 及 5.4 则要透过安装 PECL extension 安装。它的作将已经编译的 PHP Script 储存在内存, 当下次存取 PHP Script 时不用重新编译, 这样便可以提高 PHP 的效能。

以下是在 CentOS 7 安装指定 PHP 版本及设定 OPcache 的方法。

1. 在开始前先安装 EPEL Repository 及 REMI Repository:

# yum update

# yum install epel-release

# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

2. 安装 yum-utils, 这是开启 yum 的功能, 下面选择 PHP 版本时需要用上:

# yum install yum-utils

3. 安装好 yum-utils 后, 可以用 yum-config-manager 设定 Remi Repository 成默认的 Repository, 这样可以安装较新版本的 PHP (CentOS 7 内建的 PHP 版本是 5.4), 根据要安装的 PHP 版本执行以下指令:

# yum-config-manager –enable remi-php55#For PHP 5.5

# yum-config-manager –enable remi-php56#For PHP 5.6

# yum-config-manager –enable remi-php70 #For PHP 7.0

# yum-config-manager –enable remi-php71#For PHP 7.1

# yum-config-manager –enable remi-php72#For PHP 7.2

4. 现在可以用 yum 安装 OPcache:

# yum install php-opcache

如果只需要使用 OPcache 的默认设定, 则可以直接重新启动网页服务器, 如果需要设定 OPcache, 可以开启 OPcache 的设定档 /etc/php.d/10-opcache.ini

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

最后可以重新启动网页服务器:

# systemctl restart httpd

# systemctl restart nginx

你可能感兴趣的内容:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值