PHP & FreeBSD

Table of Contents

Installation
Configuration
Caching

Caching

by ross at 06:58:14 on August 1, 2014

There two ways to speed up PHP (use both):

  • Memcached: Make your code use this in-memory storage for caching results of expensive DB calls, etc.
  • Opcode optimizer: It improves PHP performance by storing precompiled script bytecode in the shared memory. This eliminates the stages of reading code from the disk and compiling it on future access.

Memcached

Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

The only problem is that the web site must be specifically written to use memcached, it's not automatic.

# cd /usr/ports/databases/memcached
# make install clean
# cd /usr/ports/databases/pecl-memcached
# make install clean

There are actually two PHP extensions for memcached: pecl-memcache and pecl-memcached. Most sites use the latter but you can install both at the same time if you need to.

Add to /etc/rc.conf:

memcached_enable="YES"

Start it:

# service memcached start

Opcode optimizers

Install only one of these.

Zend OPcache

Alternative PHP Cache (APC)

XCache

eAccelerator

 

Comments