2005-02-26, 03:35 AM
Maybe you have heard about Turck MMCache, basically it caches php code into memory to help speed up dynamic content based sites. Its a great little php addon for forums and heavily used sites. This will go through how to install mmcache for your rpm based installs for apache/php on fedora/redhat systems.
First lets download mmcache from sourceforge
Code:
wget http://superb-west.dl.sourceforge.net/sourceforge/turck-mmcache/turck-mmcache-2.4.6.tar.gz
Now lets extract it and go into the mmcache source directory
Code:
tar zxfv turck-mmcache-2.4.6.tar.gz
cd turck-mmcache-2.4.6
Now we need to set a var. If you are using the standard rpms it will be in /usr so lets set that.
Code:
export PHP_PREFIX="/usr"
Now lets compile mmcache
Code:
$PHP_PREFIX/bin/phpize
./configure --enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
make install
Now lets copy over the compiled mmcache module into the same place where the php module is installed for apache. This is just to keep it neater. You are free to put it anywhere you want. Just make sure you make the same changes below when we edit the php.ini file
Code:
cp modules/mmcache.so /usr/lib/httpd/modules/
Now lets edit the php.ini file. It is in /etc/php.ini in the rpm installs. We want to add the following lines at the bottom of the file
Code:
zend_extension="/usr/lib/httpd/modules/mmcache.so"
mmcache.shm_size="16"
mmcache.cache_dir="/tmp/mmcache"
mmcache.enable="1"
mmcache.optimizer="1"
mmcache.check_mtime="1"
mmcache.debug="0"
mmcache.filter=""
mmcache.shm_max="0"
mmcache.shm_ttl="0"
mmcache.shm_prune_period="0"
mmcache.shm_only="0"
mmcache.compress="1"
Now lets make the temp directory for mmcache and then chmod it correctly
Code:
mkdir /tmp/mmcache
chmod 777 /tmp/mmcache
Now lets restart apache
Code:
service httpd restart
Now just load up a php page on your website and you should see files in the /tmp/mmcache directory. If you don't then change the zend_extension part to extension in your php.ini and then restart apache again.
Using mmcache should increase your php content driven sites around 1-10 times their load times and bring your load down on the server also since your server isn't always re-compiling php pages over and over again