I have finished migrated this blog from Jakarta to Milan. The reason is BlackFriday coupon. Yes! I got an offer from iwStack/prometeus in LET community. I couldn’t leaving this precious offer.
On my previous server (Jakarta, CloudKilat), actually I didn’t have any issue. All thing work smoothly. But, as I said, I couldn’t leaving this precious offer.
On the previous server, I have 1 Gigs ram. I never thought about resources, but here at iwStack I have only 384 MB. So I have to save any resource.
So what exactly APC doing?
APC or Alternative PHP Cache was founded by Brian M. Shire from facebook. He did a research how to handle a significant growth of facebook. Facebook is dynamic site, everytime/everywhere people connect around the world, in the same time peoples compiled php code from the server.
That kind of thing make server load heavier. The APC founded, APC work to convert PHP source code into opcode. After that the opcode cached stored to make it even faster.
Let’s Install APC
I Installed APC on nginx, but you can install it on any webserver.
To make sure we install the latest version, we will build it from source.
apt-get install php-pear php5-dev libpcre3-dev make
pecl install apc
You will be asked few questions, you can hit enter to accept and agree with all questions. I used the following to install APC:
Enable internal debugging in APC [no] : no
Enable per request file info about files used from the APC cache [no] : no
Enable spin locks (EXPERIMENTAL) [no] : no
Enable memory protection (EXPERIMENTAL) [no] : no
Enable pthread mutexes (default) [no] : yes
Enable pthread read/write locks (EXPERIMENTAL) [yes] : no
The last thing you have to do is create the
apt-get install nano #if you don't have any
Copy this code and repleace the current one if ou have any. You don’t need to understand what is the meaning behind this. I had done the best practice to make that. All you have to understand is, how much you will allocate memory for APC in
apc.shm_size section. My case, I allocated 96 MB
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 96
apc.optimization = 0
apc.num_files_hint = 4096
apc.ttl = 7200
apc.user_ttl = 7200
apc.gc_ttl = 0
apc.cache_by_default = 1
apc.filters = ""
apc.mmap_file_mask = "/tmp/apc.XXXXXX"
apc.slam_defense = 0
apc.file_update_protection = 2
apc.enable_cli = 0
apc.max_file_size = 10M
apc.stat = 1
apc.write_lock = 1
apc.report_autofilter = 0
apc.include_once_override = 0
;apc.rfc1867 = 0
;apc.rfc1867_prefix = "upload_"
;apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
;apc.rfc1867_freq = 0
apc.localcache = 0
apc.localcache.size = 512
apc.coredump_unmap = 0
apc.stat_ctime = 0
Finaly, in order to monitor the usage you have to move
/usr/share/php/apc.php to somewhere you can access it.
Dont forget to restart the php and webserver!