HOW-TO: Install Turck MMCache

<p><font face="verdana, arial, helvetica" size="2"><b><font color="#333333">source: </font><a href="http://forum.ev1servers.net/showthread.php?s=c16323c6d2876f839cfbe7bd0932c0ba&threadid=23574"><font color="#333333">http://forum.ev1servers.net/showthread.php?s=c16323c6d2876f839cfbe7bd0932c0ba&amp;threadid=23574</font></a></b></font></p><p><font face="verdana, arial, helvetica" size="2"><b><font color="#ff0000">Updated to MMCache version 2.4.6</font></b><br /><br /><b>Turck MMCache</b> 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. <br /><br />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.<br /><br />Since version <b>2.3.10</b>, 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.<br /><br />Since version <b>2.3.15</b>, 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. <br /><br />Turck MMCache does not work in CGI mode. <br /><br />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.<br /><br />Click here for benchmark tests results:<br /><a href="http://turck-mmcache.sourceforge.net/#bench" target="_blank"><font color="#1d40f5">http://turck-mmcache.sourceforge.net/#bench</font></a><br /><br />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.<br /><br />Follow the instructions and you will uninstall PHPA or ZEND, and replace it with Turck MMCache.<br /><br /><u><b>Installation:</b></u><br /><br /><font color="#ff0000">Upgrade instructions are the same as installation. Note the lines in red which are different to previous instructions.</font><br /><br /><b>1) Login as root in SSH</b><br /><br /><b>2) Run the following commands in the following order:</b><br /><br />cd /<br /><br />mkdir mmcache<br /><br />cd mmcache<br /><br />wget http://unc.dl.sourceforge.net/sourceforge/turck-mmcache/turck-mmcache-2.4.6.tar.gz<br /><br />tar xvzf turck-mmcache-2.4.6.tar.gz<br /><br />cd turck-mmcache-2.4.6<br /><br />export PHP_PREFIX=&quot;/usr&quot; (OR export PHP_PREFIX=&quot;/usr/local&quot; -depending on where PHP is installed)<br /><br />$PHP_PREFIX/bin/phpize<br /><br />./configure --enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config<br /><br />make<br /><br />make install<br /><br /><b>3) Edit php.ini - usually it's /etc/php.ini or /usr/local/lib/php.ini</b><br /><br />Find this:<br /><br />;Windows Extensions<br /><br />Above this, comment out the PHPA or ZEND lines if you have them. Replace them with this:<br /><br /><font color="#ff0000">To install as a ZEND extension:</font><br /><br />zend_extension=&quot;/mmcache/<font color="#ff0000">turck-mmcache-2.4.6</font>/modules/mmcache.so&quot;<br />mmcache.shm_size=&quot;16&quot;<br />mmcache.cache_dir=&quot;/tmp/mmcache&quot;<br />mmcache.enable=&quot;1&quot;<br />mmcache.optimizer=&quot;1&quot;<br />mmcache.check_mtime=&quot;1&quot;<br />mmcache.debug=&quot;0&quot;<br />mmcache.filter=&quot;&quot;<br />mmcache.shm_max=&quot;0&quot;<br />mmcache.shm_ttl=&quot;0&quot;<br />mmcache.shm_prune_period=&quot;0&quot;<br />mmcache.shm_only=&quot;0&quot;<br />mmcache.compress=&quot;1&quot;<br /><br /><font color="#ff0000">OR to install as a PHP extension:</font><br /><br />extension=&quot;/mmcache/<font color="#ff0000">turck-mmcache-2.4.6</font>/modules/mmcache.so&quot;<br />mmcache.shm_size=&quot;16&quot;<br />mmcache.cache_dir=&quot;/tmp/mmcache&quot;<br />mmcache.enable=&quot;1&quot;<br />mmcache.optimizer=&quot;1&quot;<br />mmcache.check_mtime=&quot;1&quot;<br />mmcache.debug=&quot;0&quot;<br />mmcache.filter=&quot;&quot;<br />mmcache.shm_max=&quot;0&quot;<br />mmcache.shm_ttl=&quot;0&quot;<br />mmcache.shm_prune_period=&quot;0&quot;<br />mmcache.shm_only=&quot;0&quot;<br />mmcache.compress=&quot;1&quot;<br /><br /><b>4) Create the cache directory by doing the following at the command line</b><br /><br />mkdir /tmp/mmcache<br /><br />chmod 0777 /tmp/mmcache<br /><br /><b>5) Restart Apache</b><br /><br />service httpd restart<br /><br /><br />Done!<br /><br /><br />Copy the <b>mmcache.php</b> file in the mmcache directory to a directory that is web-accessible, and run it.<br /><br />You should be able to see a list of cached scripts as well as the above information. <img src="/news/images/smilies/smile.gif" border="0" /><br /><br /><b>Turck MMCache 2.4.6<br /><br />MMCache support enabled <br />Caching Enabled true <br />Optimizer Enabled true <br />Memory Size 33,554,392 Bytes <br />Memory Available 23,737,176 Bytes <br />Memory Allocated 9,817,216 Bytes <br />Cached Scripts 110 <br />Removed Scripts 0 <br />Cached Keys 0 <br /></b><br /><br /><a href="http://www.vbulletin.com/forum/attachment.php?attachmentid=7291" target="_blank"><font color="#1d40f5">http://www.vbulletin.com/forum/attachment.php?attachmentid=7291</font></a><br /><br />ALTERNATIVELY, Copy the following code into a file and save it as a PHP file, and run it:<br /><br /></font></p><blockquote><code><font face="verdana,arial,helvetica" size="1">PHP:</font> <hr /><code><font color="#000000"><br /><font color="#0000bb">&lt;?php <br />phpinfo</font><font color="#007700">(); <br /></font><font color="#0000bb">?&gt; <br /></font></font></code><hr /></code></blockquote><font face="verdana, arial, helvetica" size="2"><p><br /><br />You should see the following:<br /><br />This program makes use of the Zend Scripting Language Engine:<br />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<br /><br />As well as the info shown above.</p><p>&nbsp;</p><p>************************************</p><p /><p><font face="Verdana" size="2">Basically, <strong>to upgrade php,</strong> do this:<br /><br />1) Delete the mmcache-2.4.6 subdirectory (the one that you have untarred)<br /><br />2) Comment out mmcache lines in php.ini<br /><br />3) Restart httpd (so that mmcache no longer works - if you don't do this, httpd will not restart after php is upgraded)<br /><br />4) Upgrade to php 4.3.6<br /><br />5) Once it's up and running, untar the tarred/ zipped downloaded mmcache 2.4.6.<br /><br />6) Follow the installation instructions to recompile.<br /><br />7) Uncomment the mmcache lines in php.ini<br /><br />8) Restart httpd<br /><br />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.</font></p></font>