# mmcache not working with php

## termee

I am running apache 2.0.49 with the worker MPM. Mod_php works fine. After I  emerge turck_mmcache and restart apache, mmcache doesn't load. Here is the relevant part of my php.ini:

```

zend_extension_ts=/usr/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so

```

There is no error message in the error_log, and everything works fine, but the turck_mmcache is never loaded. What can I do to make it work?

----------

## termee

Anyone have any idea about this?

----------

## UberLord

Building it by hand shows an error in the log - undefined symbol output_globals.

I don't think the 2.4.6 ebuild plays nicely with the threadsafe version of PHP  :Sad: 

----------

## UberLord

https://bugs.gentoo.org/show_bug.cgi?id=24792

----------

## termee

So it looks like I have to wait until they release a compatible version. Are they any alternatives that will work?

----------

## UberLord

 *termee wrote:*   

> So it looks like I have to wait until they release a compatible version. Are they any alternatives that will work?

 

Well, the think is that others on the turck-mmcache lists are saying that it works - or at least one OSX user does.

I'm not too sure that we're going to see a fix anytime soon for us Gentoo users though  :Sad: 

----------

## termee

I'm gonna try building it manually. I got it to work with the Zend Optimizer, but it's not as fast as I'd like.

----------

## termee

Ok, I got it to work with PHP 4.3.5.

----------

## UberLord

OK - I'll give that a whirl  :Smile: 

----------

## UberLord

Didn't work  :Sad: 

Did you build it manually? And which version of turck-mmcache?

----------

## Ribs

Hi,

This is actually very easy to fix. Add these to the bottom of your php.ini line (usually /etc/php/apache2-php4/php.ini for Apache2 users)

```
extension="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"
```

Then re-start Apache. If you use the mmcache.php file, you will see that mmcache is indeed loaded now.

This is a bug in the ebuild, despite it saying it adds these lines to your php.ini file, it is not adding them, and thus, mmcache is never even loaded.

This software is great, I've noticed a very visible speedup on my website (which, I add, is running on my LAN, no network lag here). The page takes about 1-2 seconds to load (if that), compared to the 5-6 I was getting before.

-Ribs.

----------

## ryker

I just got turck mmcache working on my machine after reading the php.ini file comments.  I had to add the following:

```
extension=mmcache.so

extension_dir=/usr/lib/php/extensions/no-debug-non-zts-20020429

                                                                               

mmcache.shm_size=16

mmcache.cache_dir=/var/cache/mmcache

mmcache.enable=1

mmcache.optimizer=1

mmcache.check_mtime=1

mmcache.debug=0

mmcache.filter=""

mmcache.shm_max=0

mmcache.ttl=0

mmcache.shm_ttl=0

mmcache.shm_prune_period=0

mmcache.compress=1

mmcache.shm_only=0

mmcache.keys=shm_and_disk

mmcache.sessions=shm_and_disk

mmcache.content=shm_and_disk

```

I think adding the second line 'extension_dir=blah' is what I really needed to get it working.  Along with the first line of course.  The ebuild just added the 'extension=blah' with the full path.  That didn't work.  Works great now.  I also noticed the ebuild put the parameters with quotes around them; however, the rest of my php.ini didn't.  So I also took out the quotes.

----------

## jaybird

If you are using a thread safe installation of apache and I believe Gentoo's installation of Apache2.x is thread safe, then you should be starting mmcache in the php.ini file by putting: 

```
zend_extension_ts=full_path_to/mmcache.so
```

(notice the _ts on the end of zend_extension)  I'm assuming this is for Gentoo as it was with redhat.

I have tried apache2.0 on production servers and when using some php scripts I have not been able to get it to run 100% reliably as I was with apache1.3.  Having the thread safe installation of php/apache2.0 also takes a performance hit and the whole point to apache2.0 was it's threading capabilities.  So I'm going to stick to apache1.3 on my production servers.

I'm looking to replace my redhat production servers with gentoo but I'm noticing a problem with turck-mmcache on gentoo that perhaps someone has a suggestion for.

On the either the RedHat or Gentoo boxes, if I open a webpage with a php script and then look at the mmcache stats I can see it cached that script properly.  If however I alter the file on both boxes, reload that page and then check the mmcache stats again I see funny things on the Gentoo box.  RedHat replaces the cache of the file with a new one for the modified file.  On the Gentoo box it adds it to the list of cached files, though at least it uses the latest cached file.  If I run the "clean" option for mmcache, I can see it removes all older (obsolete) duplicates from memory.

Why the different behaviours between RedHat and Gentoo even with the exact same php.ini configurations?

I did notice that the turck-mmcache version that comes with gentoo is a very old and buggy.  So I manually installed version 2.4.6 on the gentoo box (they were a manual install on the redhat boxes as well).  But the behaviour is still the same.

Any thoughts?[/code]

----------

## ctwise

Make certain that you are not compiling Apache with threads support.  Do an emerge -pv apache and check for "-threads".  If you see "+threads" do USE="-threads" emerge apache.

Make certain that you are not compiling mod_php with thread support.  It will be enabled automatically if apache is compiled with "+threads" - you don't want this.  Check the php.ini file and look for directories with zts in the name, they should all be non-zts, e.g., "/usr/lib/php/extensions/no-debug-non-zts-20020429".  If you have directories like this "/usr/lib/php/extensions/no-debug-zts-20020429" then mod_php is compiled with thread support and you'll have to fix your apache install.  Run "emerge mod_php" to re-emerge after you have fixed Apache.

Once both of these issues are resolved turck-mmcache will emerge correctly.

----------

## WarrenCanuck

For those of you having trouble getting turck-mmcache to work properly with Apache 2.0 with worker mpm and thread safe php:

This will fix the undefined symbol: output_globals error.

grab turck-mmcache from CVS

untar it

then do this exactly:

phpize

./configure --enable-mmcache=shared --with-php-config=/usr/bin/php-config.mod_php

edit Makefile and add -DZTS -DPTHREADS to the DEFS = line

make

make install

then check your mod_php's php.ini to ensure that mmcache is loaded using zend_extension_ts=

restart apache and enjoy

why does this work? when php is thread safe, ouput_globals_id is defined instead of outpug_globals so we have to make sure that the php includes that turck-mmcache uses are in threadsafe mode. To do this we must ensure that ZTS and PTHREADS are defined.

----------

## vxspiritxv

I'm using apache2 + php5.0.2 + nptl + threads  :Laughing: 

WarrenCanuck method didn't exactly work for me.

What I did, that worked for me...

```
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/turck-mmcache login

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/turck-mmcache co turck-mmcache

cd turck-mmcache

phpize

CFLAGS="-march=athlon-xp -pipe -O3 -DZTS -DPTHREADS" ./configure --enable-mmcache=shared --with-php-config=/usr/bin/php-config

make
```

Didn't use zend_extension_ts ether, used extension="mmcache.so"

----------

## localghost

I have these versions of Apache, mod_php and turck_mmcache:

```
radagast ~ # emerge -pv dev-php/turck-mmcache apache mod_php

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] dev-php/turck-mmcache-2.4.6  0 kB

[ebuild   R   ] net-www/apache-2.0.52-r1  -berkdb -debug +doc +gdbm -ipv6 -ldap

+ssl -static -threads 0 kB

[ebuild   R   ] dev-php/mod_php-4.3.9  -X +apache2 -berkdb +crypt -curl -debug +

doc -fdftk -firebird -flash -freetds +gd -gd-external +gdbm -gmp -hardenedphp -i

map -informix -ipv6 -java +jpeg -kerberos -ldap -mcal -memlimit -mssql +mysql +n

ls -oci8 -odbc +pam +pdflib +png -postgres -qt -snmp +spell +ssl +tiff +truetype

 +xml2 -yaz 0 kB
```

I have this in /etc/php/apache2-php4/php.ini: (relevant part only)

```
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so

; [AVG] Added after reading http://forums.gentoo.org/viewtopic.php?t=157311

; I add all this, but really, I don't know what I'm doing here :(

zend_extension_ts=/usr/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so

extension=mmcache.so

extension_dir=/usr/lib/php/extensions/no-debug-non-zts-20020429

; [/AVG]

mmcache.shm_size=16

mmcache.cache_dir=/var/cache/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.compress=1

mmcache.shm_only=0

mmcache.keys=shm_and_disk

mmcache.sessions=shm_and_disk

mmcache.content=shm_and_disk
```

After restarting Apache, mmcache.php says that Turck MMCache is not installed.

I tried everything in this thread, except the cvs stuff because that is for threads stuff, and as you can see in my USE flags, I don't have threads in Apache. Anyway I'm afraid to break what I don't know so I'll stick with the ebuilds and stay away from manual stuff as long as possible. (for now...)

Any suggestions? Or other things I should post for further information?

----------

## xming

mmcache is renamed to eaccelerator see my site or sf.net for more info.

----------

## Akhouk

 *xming wrote:*   

> mmcache is renamed to eaccelerator see my site or sf.net for more info.

 

That looks great  :Smile: ....I was thinking that the truck_mmcache was not moving anywhere new recently.

However, I have this problem with eaccelator. I downloaded the ebuild from their site. It compiled and installed fine. However, when I try to run it ...nothing...

PHP.ini sample (as added by the ebuild)...

```

zend_extension=//usr/lib/extensions/no-debug-non-zts-20020429/eaccelerator.so

eaccelerator.shm_size="16"

eaccelerator.cache_dir="/var/cache/eaccelerator"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="0"

eaccelerator.shm_prune_period="0"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

```

and this is the output when run from the CL

```

# php /usr/share/eaccelerator/eaccelerator.php

eAccelerator 0.9.2 is not active!

It doesn't work in CGI or command line mode!

```

This is the same problem I was getting with mmcache.   :Sad: 

I am using AMD64 btw.

----------

## mipsgi

a command like "CFLAGS=\"-march=pentium4 -Os -pipe -DZTS -DPTHREADS\" emerge -av turck-mmcache" is enough, with "zend_extension_ts"

so it should be easy to be fixed in ebuild:D

----------

## deoren

I also ran across problems, but I HAD enabled threads for apache.

I'm guessing using threads enables the worker method instead of prefork for apache (makes mental note to do research)?

But anyway.

I have a another box running Fedora Core 1 with php 4.3.10, apache 2.0.53 and turck-mmcache 2.4.6 and it runs like a champ.

So, turck-mmcache works with php 4.3.10, and is it FAST!  So evidently there is not a problem with php 4.3.10 and turck-mmcache (not that I have experienced anyway).  We run a production system at work with the same setup and it's been running great for months now.

For this system, I removed apache, php, mod_php and turck-mmcache via 

```
emerge -C apache mod_php php turck-mmcache
```

 and am going to add them back now that I have added -threads to my /etc/portage/package.use file.

I'll post back with my results in a day or so (slow box).

----------

## deoren

Wha ha ha!  Fixed.   :Smile: 

It wasn't emerging everything again that fixed it either.

Here is the relevant section of php.ini:

 *Quote:*   

> ; Enable Turck MMCache extension module
> 
> ;zend_extension = mmcache.so
> 
> extension = mmcache.so
> ...

 

Nothing something different?  It doesn't say zend_extension, it says extension.

From the turck-mmcache site, Step 3:  *Quote:*   

> Turck MMCache can be installed both as Zend or PHP extension

 

http://turck-mmcache.sourceforge.net/index_old.html#install

I am going to recompile using threads and see if it still likes me.   :Smile: 

----------

## deoren

 *mipsgi wrote:*   

> a command like "CFLAGS=\"-march=pentium4 -Os -pipe -DZTS -DPTHREADS\" emerge -av turck-mmcache" is enough, with "zend_extension_ts"
> 
> so it should be easy to be fixed in ebuild:D

 

Should we open a bug about this?

As I mentioned previously I was going to try again with threads (not using any CLI tricks) enabled for apache, and it didn't work: as expected.

Shouldn't an ebuild of turck-mmcache be written to accept use flags like threads?

----------

## deoren

 *deoren wrote:*   

>  *mipsgi wrote:*   a command like "CFLAGS=\"-march=pentium4 -Os -pipe -DZTS -DPTHREADS\" emerge -av turck-mmcache" is enough, with "zend_extension_ts"
> 
> so it should be easy to be fixed in ebuild:D 
> 
> Should we open a bug about this?
> ...

 

Here is a relevant bug for this issue: https://bugs.gentoo.org/show_bug.cgi?id=83553

----------

## deoren

 *mipsgi wrote:*   

> a command like "CFLAGS=\"-march=pentium4 -Os -pipe -DZTS -DPTHREADS\" emerge -av turck-mmcache" is enough, with "zend_extension_ts"
> 
> so it should be easy to be fixed in ebuild:D

 

I added  *Quote:*   

> -DZTS -DPTHREADS

  to my CFLAGS in /etc/make.conf and emerged turck-mmcache after I had emerged apache with thread support enabled, followed by php and mod_php.

I then removed those settings from  my CFLAGS so they would not affect other applications.

Here is my experience:

zend_extension_ts = mmcache.so Doesn't work

zend_extension = mmcache.so Doesn't work

extension = mmcache.so Works fine.

It seems no matter what only the last one will effectively load the module.  Perhaps earlier versions of turck-mmcache behaved differently?

----------

## deoren

I just thought I'd post back to this thread to point out that turck-mmcache has been removed from portage so the steps I mentioned are pretty much a moot point.

I'll end up giving eaccelerator a try in a week or so once I rebuild apache2 + php so threading will be disabled (have read on these forums where threads + eaccelerator is a "no go").

----------

