ownCloud Tuning

最後更新: 2023-11-24

ownCloud Server Tuning

 

 - Using cron to perform background jobs
 - Locking & Caching (Redis)
 - JavaScript and CSS Asset Management (concatenated and compressed format)
 - Database Best Practice (localhost to 127.0.0.1)
 - Apache Tuning

 


Configure the cron Jobs

 

crontab -e -u apache

echo "*/15  *  *  *  * /var/www/owncloud/occ system:cron" \
  | sudo -u www-data -g crontab tee -a \
  /var/spool/cron/crontabs/www-data
echo "0  2  *  *  * /var/www/owncloud/occ dav:cleanup-chunks" \
  | sudo -u www-data -g crontab tee -a \
  /var/spool/cron/crontabs/www-data

 


php code Caching

 

  • xcache
  • OPcache

xcache

/etc/php5/conf.d/xcache.ini

xcache.var_size  =           16M
xcache.stat   =              Off
xcache.optimizer =            On
xcache.admin.enable_auth =   Off

xcache admin 不能設定 login, 否則會有以下 Error

{"app":"core","message":"XCache opcode cache will not be cleared because 
\"xcache.admin.enable_auth\" is enabled.","level":2,"time":"2014-05-17T14:39:13+00:00"}

OPcache

# Test on OC V10

/etc/opt/remi/php74/php.d/10-opcache.ini

opcache.memory_consumption=64
opcache.optimization_level=0xffffffff

 * 必須保留 comments, 因為 owncloud 依賴它

opcache.save_comments=1
opcache.load_comments=1

 


Locking & Caching (Redis)

 

ownCloud 有多個 cache 方案, 包括 apcu, memcahe, redis

If you are limited in memory or only want to have one caching backend, use Redis for both.

redis on Rocky 8

dnf install redis # redis-5.0.3

usermod -G redis -a apache

mkdir -p /var/run/redis

chown -R redis:apache /var/run/redis

vim /etc/redis.conf

unixsocket /var/run/redis/redis.sock
unixsocketperm 770

systemctl enable redis --now

ls -lh /var/run/redis

srwxrwx--- 1 redis redis 0 Nov 22 16:42 redis.sock

dnf install php74-php-pecl-redis5

php -m | grep redis

redis

systemctl restart php74-php-fpm

ownCloud Settings

sudo -u apache -s /bin/bash

locking

./occ config:system:set \
   memcache.local \
   --value '\OC\Memcache\Redis'

cache

./occ config:system:set \
   memcache.locking --value '\OC\Memcache\Redis'

redis use unix port

./occ config:system:set \
   redis \
   --value '{"host": "/var/run/redis/redis.sock", "port": "0"}' \
   --type json

 


Apache Tuning

 

* Enable http2

Protocols h2 http/1.1

詳見

* Enables persistent HTTP connections

KeepAlive On
KeepAliveTimeout 3
MaxKeepAliveRequests 200

* DNS Lookup

HostnameLookups off

* Log files should be switched off (CustomLog)

CustomLog /dev/null combined

 

Creative Commons license icon Creative Commons license icon