Jump to content

install mmcache for php


Recommended Posts

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

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

 

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.

 

export PHP_PREFIX="/usr"

 

Now lets compile mmcache

 

$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

 

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

 

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

 

mkdir /tmp/mmcache
chmod 777 /tmp/mmcache

 

Now lets restart apache

 

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

  • Like 2
Link to post
Share on other sites
  • 2 weeks later...

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. :ph34r:

Link to post
Share on other sites

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

 

$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>";

Link to post
Share on other sites

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..

 

-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. :ph34r:

Link to post
Share on other sites
  • 1 month later...
  • 11 months later...

After switching to fc5 with php5 I tried to recompile and am getting the following:

<root@uin turck-mmcache-2.4.6> make
/bin/sh /build/turck-mmcache-2.4.6/libtool --mode=compile gcc  -I. -I/build/turck-mmcache-2.4.6 -DPHP_ATOM_INC -I/build/turck-mmcache-2.4.6/include -I/build/turck-mmcache-2.4.6/main -I/build/turck-mmcache-2.4.6 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext  -DHAVE_CONFIG_H  -g -O2   -c /build/turck-mmcache-2.4.6/mmcache.c -o mmcache.lo
mkdir .libs
gcc -I. -I/build/turck-mmcache-2.4.6 -DPHP_ATOM_INC -I/build/turck-mmcache-2.4.6/include -I/build/turck-mmcache-2.4.6/main -I/build/turck-mmcache-2.4.6 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /build/turck-mmcache-2.4.6/mmcache.c  -fPIC -DPIC -o .libs/mmcache.o
/build/turck-mmcache-2.4.6/mmcache.c: In function 'fixup_zval':
/build/turck-mmcache-2.4.6/mmcache.c:705: error: 'empty_string' undeclared (first use in this function)
/build/turck-mmcache-2.4.6/mmcache.c:705: error: (Each undeclared identifier is reported only once
/build/turck-mmcache-2.4.6/mmcache.c:705: error: for each function it appears in.)
/build/turck-mmcache-2.4.6/mmcache.c: In function 'calc_zval':
/build/turck-mmcache-2.4.6/mmcache.c:1293: error: 'empty_string' undeclared (first use in this function)
/build/turck-mmcache-2.4.6/mmcache.c: In function 'store_zval':
/build/turck-mmcache-2.4.6/mmcache.c:1652: error: 'empty_string' undeclared (first use in this function)
/build/turck-mmcache-2.4.6/mmcache.c: In function 'restore_zval':
/build/turck-mmcache-2.4.6/mmcache.c:2159: error: 'empty_string' undeclared (first use in this function)
/build/turck-mmcache-2.4.6/mmcache.c: In function 'ps_create_sid_mmcache':
/build/turck-mmcache-2.4.6/mmcache.c:4004: error: 'empty_string' undeclared (first use in this function)
make: *** [mmcache.lo] Error 1

 

Any suggestion?

Link to post
Share on other sites

Hi,

 

In Fedora Core 5 you could installe:

 

php-eaccelerator.i386 5.1.2_0.9.3-0.3.fc5 extras

Matched from:

eAccelerator is a further development of the MMCache PHP Accelerator & Encoder.

It increases performance of PHP scripts by caching them in compiled state, so

that the overhead of compiling is almost completely eliminated.

Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...