Friday, March 22, 2013

Enabling APC for performance improvement


APC (Alternative PHP Cache) is an opcode cache that can significantly speed up your PHP applications, by caching both PHP code and user variables. Adding APC to an application usually results in improved application response times, reduced server load and happier users.

Install dependencies:
apt-get install libpcre3-dev

Install apc (a current version):
pecl install apc

Note where apc.so is installed to:
find / -name apc.so 2>/dev/null

Find the php.ini file so you can update it:
find / -name php.ini 2>/dev/null

Edit php.ini with your favorite editor:
nano /pathTo/php.ini 

Somewhere in you php.ini file add please not that path may be different for you installation
extension="/usr/pathTO/php/modules/apc.so"
apc.enabled=1

Copy the shipped apc.php to see what is going on wit apc on your server
cp /usr/share/pear/apc.php /root_dir_of_your_web_app

Restart you ownCloud server:

sudo /etc/init.d/apache2 restart


Run through your ownCloud site using a browser.

Examine the performance of your cache via browser (confirms APC working):
http://hostname:port/owncloud/apc.php

To validate from the command line:
$ php --ri apc

apc

APC Support => enabled
Version => 3.1.13
APC Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>  
Locking type => pthread read/write Locks
Serialization Support => php
Revision => $Revision: 327136 $
Build Date => Mar 22 2013 19:36:36

Directive => Local Value => Master Value
apc.enabled => On => On
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.include_once_override => Off => Off
apc.num_files_hint => 1000 => 1000
apc.user_entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.ttl => 0 => 0
apc.user_ttl => 0 => 0
apc.mmap_file_mask => no value => no value
apc.filters => no value => no value
apc.cache_by_default => On => On
apc.file_update_protection => 2 => 2
apc.enable_cli => On => On
apc.max_file_size => 1M => 1M
apc.stat => On => On
apc.canonicalize => On => On
apc.stat_ctime => Off => Off
apc.write_lock => On => On
apc.slam_defense => On => On
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_freq => 0 => 0
apc.rfc1867_ttl => 3600 => 3600
apc.coredump_unmap => Off => Off
apc.preload_path => no value => no value
apc.file_md5 => Off => Off
apc.use_request_time => On => On
apc.lazy_functions => Off => Off
apc.lazy_classes => Off => Off
apc.serializer => default => default



No comments:

Post a Comment