Owncloud 8之後支援PHP的快取(caching)技術,能讓owncloud的效能提升,官方文章在這:
Making ownCloud Faster Through Caching
但是CentOS 7 預設的PHP版本為5.4,作為一個保守的Linux發行版本,官方並未提供5.5或更高版本的支援,
要使用效能更好的快取功能,owncloud建議使用PHP 5.5以上版本,對CentOS 7來說就有點麻煩了,
所以要先做的就是先將PHP升級到5.5或更高版本吧,我個人是選擇直接升級到5.6。
要升級PHP必須先加入remi程式庫源:
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm
這時候remi源就會被加入程式庫當中。
要升級PHP到5.5或5.6,需修改
/etc/yum.repos.d/remi.repo 這個檔案,使用你習慣的文字編輯器修改:
[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php55/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/php55/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/php56/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
以上enabled預設為0,看你要安裝的是5.5或是5.6版,打開相對應的enabled選項為1,
以上述設定來說,我要安裝5.6版就把php56中的enabled改為1。
升級前先將相關服務關閉,centos 7下的指令:
systemctl stop httpd
systemctl stop mysqld
centos 6.5之前版本下指令:
service httpd stop
service mysqld stop
然後執行yum升級:
yum update -y
yum update php
升級後檢查版本是不是已經升級完畢:
# php -v
PHP 5.6.22 (cli) (built: May 26 2016 15:36:45)
Copyright (c) 1997-2016 The PHP Group
看到 5.6.xx就表示php已經升級成功。
不過PHP升級到5.5或5.6,預設是沒有開啟快取(cache)功能,需要手動設定。
先安裝以下套件:
yum -y install yum-plugin-priorities
因owncloud支援的PHP 5.6 caching模式為APCu,所以要安裝相關的模組:
yum install php-pecl-apcu --enablerepo=remi-php56,remi
安裝完之後開啟以下檔案:
/etc/php.d/40-apcu.ini
修改以下內容:
apc.enabled=1
apc.enable_cli=0
apc.shm_size=32M
apc.ttl=3600
apc.gc_ttl=3600
apc.mmap_file_mask=/tmp/apc.XXXXXX
重點就是enabled要設為1
然後重啟相關服務:
systemctl start httpd
systemctl start mysqld
保險起見也可以將系統重開:
reboot
修改owncloud 設定檔中的快取設定:
/var/www/html/owncloud/config/config.php
加入以下這行設定:
'memcache.local' => '\OC\Memcache\APCu',
之後用瀏覽器進入owncloud的後台管理頁面,沒出現cache警告就表示一切設定都正確。
參考網址: