Jump to content

Installing extensions (memcache) on OSX, and generally how does php/apache work?


Recommended Posts

Hello there!

 

Let me firstly say that I've looked *everywhere* for an answer to this before bothering you very busy people. I've searched tons of forums, but no luck  :-[

 

Secondly, just to let you know, I'm a total newbie to php configuration and am therefore pretty confused about what's going on/wrong here.  ??? Here's the problem...

 

I'm trying to use memcache, but I'm guessing the question applies to any php module. I installed the php memcache extension which seemed to go well and it's now in /usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so - this seems like an odd place to me but I'm told it's right.

 

I have a php file that tries to instantiate it, simply:

 

<?php 

  $mem = new Memcache;

  phpinfo();

?>

 

Now, if I look at that file through Apache, I get a fatal error - "Class 'Memcache' not found in..." But if I look at that file via php in terminal (php file.php) no problems, I get phpinfo back. If I look at phpinfo through Apache, the memcache extension doesn't show up in the list, but if I look it through the command line it does. What's spookier (for me at least) is if I remove the php executable from /usr/bin/ and restart apache, I can still run php scripts on the webserver! How's that?

 

In apache I have:

 

LoadModule php5_module        libexec/apache2/libphp5.so

 

which I subsequently found in /usr/libexec/apache2. So is this an entirely separate instance of php to the one in usr/bin/? If so, how do I get php through Apache to see my new module? If not, I'm totally confused.  ??? Can anyone shed any light as to what's going on here?

 

Many many many thanks in advance.

 

5forty

Link to comment
Share on other sites

Firstly, you need to restart Apache before any changes can take affect.

 

if I remove the php executable from /usr/bin/ and restart apache, I can still run php scripts on the webserver! How's that?

 

The php executable within /usr/bin is php's cli (command line interface) and is completely separate from mod_php which is an Apache module that interprets php scripts within the webserver context.

 

It is likely that the two (php-cli and mod_php) have two differnet config files (php.ini).

 

Have you made any changes to any php.ini ?

 

Make a script....

 

<?php
   phpinfo();
?>

 

Run it via Apache. Find where your php.ini file is located for mod_php, then add the following line and restart the server.

 

extension=memcache.so

Link to comment
Share on other sites

Hi Thorpe!

 

Thanks very much for your reply. That certainly cleared-up my understanding of CLI and mod-php. Thanks for that!  :)

 

So oddly(?) both the CLI and mod-php were both using the same php.ini in /private/etc/php.ini - is that normal?

 

So I followed your instruction and found that I'd already put the extension declaration in the ini (I'd obviously forgotten after trying so many things):

 

extension=memcache.so

 

and made sure the extension dir was set correctly

 

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

 

I've restarted apache (and checked that it went down and up by making requests to it), but mod-php still bails by saying it can't find the Memcache class.

 

Anything else I can try?

 

Thanks very much again for helping me out!  ;D

 

5forty

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.