Portal Home > Knowledgebase > Articles Database > Apache, PHP and Memcache ... something isn't meshing
Apache, PHP and Memcache ... something isn't meshing
Posted by zhanng, 04-22-2011, 10:15 PM |
Hello.
I have one last major issue with my migration from 1and1 to bluemile, and that's memcache. I have actually setup memcache many times in the past, but for some reason this time it isn't working. I can see that the service is running on port 11211, but when I try connecting from PHP it always fails.
Anyone have any idea where I can look?
Thanks
Dan
|
Posted by GameFrame, 04-25-2011, 06:57 AM |
Have you recently built your PHP from source, if you have, you have to recompile the module as well.
Check also your php.ini which need the following settings:
extension=memcache.so
session.save_handler = memcache
session.save_path = "tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
memcache.hash_strategy = "consistent"
memcache.max_failover_attempts = 100
memcache.allow_failover = 1
Memcached startup:
memcached -u daemon -d -l 127.0.0.1 -t 4 -m 1024 -R 40 -c 2048 -I 12m
If your users are not experiencing strange session related issues you may want to change "12m" to something like 1m which is the maximum allowed size for each single session.
PS. I remember having an issue with squirrelmail if the mailbox has around 10K emails, it requires several megabytes session to be allowed for memcached such as 12m or you will get disconnected.
Last edited by GameFrame; 04-25-2011 at 07:05 AM.
|
Posted by zhanng, 04-25-2011, 09:35 AM |
I tried adding those lines to my php.ini, but it didn't help.
I installed PHP, as well as everything else, via yum.
For the most part, everything points to the fact that memcache is working. I can telnet to it, netstat -an | grep 11211 shows it ... however, php just can't connect. When I try, I get the following error:
[24-Apr-2011 17:15:01] PHP Warning: Module 'memcache' already loaded in Unknown on line 0
[24-Apr-2011 17:15:01] PHP Notice: Memcache::connect(): Server localhost (tcp 11211) failed with: Connection refused (111) in /var/www/html/url/algorithm.php on line 131
It seems like there is some disconnect between either PHP, Apache and Memcached ... but, for the life of me, I can't figure out what. I have setup memcache several times in the past, each time with no difficulties ... this time, it decides to be difficult.
Maybe doing a complete removal and re-installation of memcached would work? The problem, how do I know for sure I removed all traces of it? I have gone through so many online instructions that at this point I don't have a clue as to whats installed ... it is very possible that I installed two conflicting instances.
|
Posted by asciiDigital, 04-25-2011, 01:25 PM |
Are you sure memcache is actually compiled into PHP. Try running this command:
|
Posted by zhanng, 04-25-2011, 01:27 PM |
Yeah ... its installed. Just in case I tried it again and got the following:
Skipping package "pecl/memcache", already installed as version 2.2.6
No valid packages found
install failed
If you think you're frustrated, just imagine how I feel ... I have been trying to figure this out for almost a week now.
|
Posted by GameFrame, 04-26-2011, 06:47 AM |
Remove duplicate extension lines from your php.ini, verify also that you have defined other settings only once. Can you paste the line 131 from /var/www/html/url/algorithm.php ?
Assuming your web server runs under 'nobody' user, do this under root:
su nobody
telnet localhost 11211
Do you get connect under that user?
|
Posted by zhanng, 04-26-2011, 09:16 AM |
I looked over my php.ini and didn't find any duplicate memcache declarations. All that I have regarding memcache is the following:
As for the nobody account, when I try typing 'su nobody' I get the following:
This account is currently not available.
Interestingly enough, I was under the impression that the Apache user was being used by apache, so I tried 'su apache' to see if I could connect, but got the same message.
|
Add to Favourites Print this Article
Also Read