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 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:
# service memcached start
Install only one of these.
- Install www/pecl-zendopcache
- Parameters: https://php.net/manual/en/opcache.installation.php
Alternative PHP Cache (APC)
- Install www/pecl-APC
- Parameters: https://php.net/manual/en/apc.configuration.php
- Install www/xcache
- Parameters: http://xcache.lighttpd.net/wiki/XcacheIni
- Install www/eaccelerator
- Parameters: https://github.com/eaccelerator/eaccelerator