Updated to MMCache version 2.4.6
Turck MMCache is a free open source PHP accelerator, optimizer, encoder and dynamic content cache for PHP. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. Also it uses some optimizations to speed up execution of PHP scripts. Turck MMCache typically reduces server load and increases the speed of your PHP code by 1-10 times.
Turck MMCache stores compiled PHP scripts in shared memory and execute code directly from it. It creates locks only for short time while search compiled PHP script in the cache, so one script can be executed simultaneously by several engines. MM shared memory library (http://www.engelschall.com/sw/mm/) was used by Turck MMCache before version 2.3.13 for management of shared memory and locking. Files those can't fit in shared memory are cached on disk only.
Since version 2.3.10, Turck MMCache contains a PHP encoder and loader. You can encode PHP scripts using encoder.php in order to distribute them without sources. Encoded files can be run on any site which runs PHP with Turck MMCache 2.3.10 or above. The sources of encoded scripts can't be restored because they are stored in a compiled form and the encoded version doesn't contain the source. Of course, some internals of the scripts can be restored with different reverse engineering tools (disassemblers, debuggers, etc), but it is not trivial.
Since version 2.3.15, Turck MMCache is compatible with Zend Optimizer's loader. Zend Optimizer must be installed after Turck MMCache in php.ini. If you don't use scripts encoded with Zend Encoder then we do not recommend you install Zend Optimizer with Turck MMCache.
Turck MMCache does not work in CGI mode.
Turck MMCache now BEATS Zend Accelerator and all other PHP accelerators in benchmark tests. So it's currently the BEST PHP accelerator around, even against commercial products, despite being free.
Click here for benchmark tests results:
The instructions in this How-To is a bit different to the official one, because the directories are a bit different - I couldn't get this to work using the instructions from the site itself.
Follow the instructions and you will uninstall PHPA or ZEND, and replace it with Turck MMCache.
Upgrade instructions are the same as installation. Note the lines in red which are different to previous instructions.
1) Login as root in SSH
2) Run the following commands in the following order:
tar xvzf turck-mmcache-2.4.6.tar.gz
export PHP_PREFIX="/usr" (OR export PHP_PREFIX="/usr/local" -depending on where PHP is installed)
./configure --enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config
3) Edit php.ini - usually it's /etc/php.ini or /usr/local/lib/php.ini
Above this, comment out the PHPA or ZEND lines if you have them. Replace them with this:
To install as a ZEND extension:
OR to install as a PHP extension:
4) Create the cache directory by doing the following at the command line
chmod 0777 /tmp/mmcache
5) Restart Apache
service httpd restart
Copy the mmcache.php file in the mmcache directory to a directory that is web-accessible, and run it.
You should be able to see a list of cached scripts as well as the above information.
Turck MMCache 2.4.6
MMCache support enabled
Caching Enabled true
Optimizer Enabled true
Memory Size 33,554,392 Bytes
Memory Available 23,737,176 Bytes
Memory Allocated 9,817,216 Bytes
Cached Scripts 110
Removed Scripts 0
Cached Keys 0
ALTERNATIVELY, Copy the following code into a file and save it as a PHP file, and run it:
You should see the following:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies with Turck MMCache v2.4.6, Copyright (c) 2002-2003 TurckSoft, St. Petersburg, by Dmitry Stogov
As well as the info shown above.
Basically, to upgrade php, do this:
1) Delete the mmcache-2.4.6 subdirectory (the one that you have untarred)
2) Comment out mmcache lines in php.ini
3) Restart httpd (so that mmcache no longer works - if you don't do this, httpd will not restart after php is upgraded)
4) Upgrade to php 4.3.6
5) Once it's up and running, untar the tarred/ zipped downloaded mmcache 2.4.6.
6) Follow the installation instructions to recompile.
7) Uncomment the mmcache lines in php.ini
8) Restart httpd
Done! Mmcache should now be working! The trick to remember is that you always need to uninstall mmcache when upgrading php, and then recompile mmcache after php is upgraded.