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
你可能感興趣的內容:
總結
以上是生活随笔為你收集整理的centos php redhat,RHEL / CentOS 安装 OPcache 提升 PHP 效能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 5.7 ssd_6T!阿里云
- 下一篇: 请编写一个程序,请将字符串中所有字母全部