Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memcache

Status
Not open for further replies.

junkie8

Technical User
Aug 9, 2009
32
US
I have memcache installed on my RHEL machine. The following script works perfectly when I execute the php script at the command prompt. However, when I try to execute this script from a browser, it returns 'Could not connect'.

I have:
- changed localhost to 127.0.0.1
- checked the port 11211 and it is open
- ps -eaf | grep memcached returns
00:00:00 memcached -d -p 11211 -u memcached -m 255 -c 1024 -/var/run/memcached/memcached.pid
which means any IP is allowed on port 11211.

What am I missing?

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ('Could not connect');

$version = $memcache->getVersion();
echo 'Server’s version: '.$version;

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$numb = array("numb" => 45, "Love" => "Life");

$memcache->set('GOLD', 44, false, 5000) or die ('Failed to save data at the server');

$_SESSION['client_id'] = 45;
echo 'Store data in the cache (data will expire in 10 seconds)';
 
A browser connects with the permissions of the Apache user which probably has no permissions to access memcache.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top