Reputation: 37
I have LAMP based PHP & MySql web application hosted on digitalocean separate servers in Singapore region. One PHP server + one remote MySql DB server, both are working fine. Because the app has to read more than the write, I wanted to add one memcache server.
What I've tried so far: - Use these steps from this tutorial on a 2gb droplet.
Now I have a one memcache server with public ip:129.x.x.x
and private ip:10.x.x.x
,
1-p 11211
2.-m 2048
3.-c 1024
4.-l 127.0.0.1
memcached server successfully installed and cached the test data on localhost. But I want to use this on other remote web server,
So I have changed in memcached.conf
file -l 127.0.0.1
to THIS memcached server private IP -l 10.x.x.x
.
Now when I check on memcached server and type ps aux | grep memcached
it shows:
tcp 0 0 10.x.x.x:11211 *:* LISTEN 3742/memcached
When I check stats echo "stats settings" | nc 10.x.x.x 11211
it shows that all things about memcached server and it is running.
For testing purposes I made a file test.php
and save on PHP server and try to connect.
<?php
$mc = new Memcached();
$mc->addServer("**10.x.x.x**", 11211);
$result = $mc->get("test_key");
if($result) {
echo $result;
} else {
echo "No data on Cache. Please refresh.";
$mc->set("test_key", "test data from Cache!") or die ("Failed to save data at Memcached server");
}
?>
But it is always showing an HTTP ERROR 500
error page, a"page isn’t working error on PHP server, 192.x.x.x is currently unable to handle this request
but my other PHP and MySql app running on same server.
The same code is running and caching data successfully on memcached server but not working in remote PHP server.
When I try telnet 10.x.x.x 11211
it is connecting successfully, sudo iptables -L
outputs that INPUT policy ACCEPT anywhere.
I've tried a lot of googling but it is not helping me with anything.
Upvotes: 2
Views: 1420
Reputation: 37
After checking web server error logs , that shows
Class 'Memcached' not found
. i have to install memcached php module in web server in order to connect to remotely memcached instance . by typing
apt-get install php5-memcached
and change in php.ini by adding
extension = memcached.so
,
than php web server start connected to remotely memcached server . if you want to use memcached for session's than open php.ini file and add
session.save_handler = memcache
session.save_path = 'tcp://10.x.x.x:11211'
and finally, restart server .
Upvotes: 0