5forty Posted December 2, 2008 Share Posted December 2, 2008 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 Quote Link to comment Share on other sites More sharing options...
trq Posted December 2, 2008 Share Posted December 2, 2008 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 Quote Link to comment Share on other sites More sharing options...
5forty Posted December 2, 2008 Author Share Posted December 2, 2008 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! 5forty Quote Link to comment Share on other sites More sharing options...
5forty Posted December 2, 2008 Author Share Posted December 2, 2008 ...mmm and the phpinfo() still doesn't list the extension under apache, but does via command line... ??? 5F Quote Link to comment Share on other sites More sharing options...
trq Posted December 2, 2008 Share Posted December 2, 2008 Have you checked phpinfo() within the cli to make sure its also using the same php.ini? Sounds like you have, just checking though. Quote Link to comment Share on other sites More sharing options...
5forty Posted December 2, 2008 Author Share Posted December 2, 2008 Hi Thorpe, yes, they're both using the same ini. To make 100% sure I even turned the engine off in the ini and then checked that both apache and command line failed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.