Memcached server with multiple webservers

I’m struggling for days now, I’m setting up my cloud infrastructure:
1 nginx Loadbalancer
2 Centos Webservers
1 Centos Memcached server

On the webservers I’ve installed the php-pecl-memcached packages and made the necessary adjustments to php.ini. The webservers connect to the memcached server over a private network:

session.save_handler = memcached
session.save_path = "10.xx.xx.xx:11211"

The webservers are capable of connecting, tested it with telnet 10.xx.xx.xx 11211 and the memcached server is able to output the statistics when you type stats.

Now trying to check if Memcached works as it should results in a PHP error:

HP Warning:  Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0, referer: https://example.com

It looks like the session.save_path as mentioned above isn’t used, while it should be accessible, see telnet test.

Answer

Fixed! Seemed that there was another config file overriding the php.ini settings. Check the /etc/php.d/ folder for a memcached.ini file. Override the settings in this file.

Attribution
Source : Link , Question Author : Peter Fox , Answer Author : Peter Fox

Leave a Comment