Linux-Noob Forums

Full Version: install mmcache for php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

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

worked great on fc1, thanks man. :)

Hi,

 

Im using FC3 and i get stuck at "$PHP_PREFIX/bin/phpize" just after Now lets compile mmcache, that isnt a valid location for me!?

 

-bash-3.00# $PHP_PREFIX/bin/phpize

-bash: /usr/bin/phpize: No such file or directory

 

is the response i get, what am i doing wrong?

 

Cheers

Carl. [img]<___base_url___>/uploads/emoticons/default_ph34r.png[/img]


Quote:-bash-3.00# $PHP_PREFIX/bin/phpize-bash: /usr/bin/phpize: No such file or directory
 

it is included in the php-devel rpm


Here is a simple benchmark I used to test using php v4.3.10 using mmcache vs no cache at all. I tested it by hitting the Invision Power Board forum index page 100 times over and over again

 

This are average load times for php to serve up the page

 

No Cache: 0.10593454837799

MMcache: 0.046741628646851

 

So doing some simple math.. we see that using mmcache will speed up the load time by 4 million percent :)ok not 4 million but i believe its around 226%. Thats pretty darn good

 

Here is the script I used

 



Code:
$file = "http://domain.com/forum/index.php";
$iter = 100;


function getmtime()
{
$a = explode (' ',microtime());
return(double) $a[0] + $a[1];
}

for ($i = 0; $i < $iter; $i++)
{
$start = getmtime();
file ($file);
$loadtime += getmtime() - $start;
$intertime = getmtime() - $start;
echo $intertime . "<br>";
$avgload = $loadtime / $iter;
}
echo "<p><b>" . $avgload . "</b>";





Installed Php-devel and when i tryed to do "$PHP_PREFIX/bin/phpize"

 

I got the error "aclocal: command not found"

 

so I googled and found i had to install autoconf and automake

did that then i got the following..

 



Code:
-bash-3.00# $PHP_PREFIX/bin/phpize
configure.in:9: warning: underquoted definition of PHP_WITH_PHP_CONFIG
 run info '(automake)Extending aclocal'
 or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
configure.in:32: warning: underquoted definition of PHP_EXT_BUILDDIR
configure.in:33: warning: underquoted definition of PHP_EXT_DIR
configure.in:34: warning: underquoted definition of PHP_EXT_SRCDIR
configure.in:35: warning: underquoted definition of PHP_ALWAYS_SHARED
acinclude.m4:19: warning: underquoted definition of PHP_PROG_RE2C
configure.in:65: error: possibly undefined macro: AC_PROG_LIBTOOL
     If this token and others are legitimate, please use m4_pattern_allow.
     See the Autoconf documentation.




 

any clues on what i should do? ignore it?

 

 

Carl. [img]<___base_url___>/uploads/emoticons/default_ph34r.png[/img]

make sure you have libtool and libtool-libs installed

Quote:make sure you have libtool and libtool-libs installed

 

Thanks that and installing gtk+ & gcc-c++ solved my problems

 

Carl [img]<___base_url___>/uploads/emoticons/default_ph34r.png[/img]


hi everyone

 

did anyone install mmcache with Centos 3.4 ? if so, would you mind share your experience ? i have tried , but it seems like something wrong

what error did you get?
Pages: 1 2