how to install Separate memcache server on ubuntu and Use from other server ?

April 29, 2016 595 views
PHP Caching LAMP Stack Ubuntu

I have one custom made php & mysql web application , hosted in separate server's ,in Singapore region . one php server + one mysql db server , both working fine . because , app have read more than the write , So i want to add a one memcache server .
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 change in memcached.conf file
-l to memcached server private ip 10.x.x.x .
On php server , try to connect memcached server but its always shows a HTTP ERROR 500 error page , page isn’t working error .

tried lots of googling this but not helping any thing !
Do i have to install any connector ON PHP app server to connect with memcached server on private ip .

2 Answers


You are on the correct path. Once you've configured memcached to listen on the private IP address, you need to configure PHP to connect to that IP address for memcached.

Open /etc/php5/fpm/php.ini in your favorite text editor and update the following settings:

session.save_handler = memcache
session.save_path = 'tcp://'

Finally, restart php5-fpm so that the changes take effect:

sudo service php5-fpm restart

If you still get a 500 error after doing that, check nginx's error logs (which is where php5-fpm's errors should go) and see if there are any details in there:

sudo tail -20 /var/log/nginx/error.log

hey @kamaln7 thanks for response , yes i have checked the php based web server's error logs , that says
2016/04/29 05:01:28 [error] 4355#0: *494 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'Memcached' not found in /var/www/test.php .

So when i install memcached on web server apt-get install php5-memcached , & added in php.ini extension = memcached.so , than php web server start connected to remotely memcached server , now everything works fine ,

So is this right way to connect other server ? do we have too install memcached in web server ?

  • Yes, that is the correct way to do it. You still need the memcached php module in order to connect to your memcached instance, otherwise, php wouldn't know how to do that. You don't need to run memcached itself, though.

Have another answer? Share your knowledge.