Setting up memcache with Sugar on Windows

sugarcrmdevelopers —  April 29, 2013 — Leave a comment

Editor’s Note: This originally appeared in this forums post, but wanted to get the solution more out in front of the board Sugar community so I reposted it here. Thanks to duprazm for contributing this!

Here is a small tutorial for Windows users about how to install memcached on a server-client deployment and make it work with SugarCRM 6.5.

You will need 2 machines (i think it should work also with one but i haven’t tried yet) running Windows Server 2008 (R2), one with SugarCRM 6.5 installed (the client) and one without (the server) over which you will install memcached.

You may find the 2 binaries needed here and here.

Remember that memcached and memcache are not the same (memcahed is the server which contains the hash table and memcache is the client interface).

Server (memcached):

1. Unzip memcached-1.2.6-win32-bin.zip into a suitable directory (i.e. C:Program Files (x86)Memcached)
2. Open CMD, move to the memcached directory and run this command to install memcached: memcached.exe -d install
3. Open “Administrative Tools -> “Services” and search for the memcached service, be sure is set to autostart (in case of a reboot) and start it
4. Once it’s started, open Regedit and go to this key: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservic esmemcachedimagepath and modify it like this: “[Path to Memchaed]memcached.exe” -d runservice -m xxx where xxx is the amount of memory you want to allocate to memcached (I suggest 1024 to begin with)
5. Go once again to “Administrative Tools -> “Services” and restart the memcached service.
6. Done for the server 

Client (SugarCRM):

1. Unizip php_memcache-2.2.6-5.3-nts-vc9-x86.zip and copy php_memcache.dll to your php extension path (if you have multiple PHP installation be sure that this is the one Sugar’s web server is running).
2. Modify your php.ini adding this line extension=php_memcache.dll and save the file
3. Open your Sugar’s config_override.php and add those line (where xxx.xxx.xxx.xxx is the remote server ip address running memcached (as setup before)):

$sugar_config['external_cache']['memcache']['host'] = 'xxx.xxx.xxx.xxx';
$sugar_config['external_cache_disabled_apc'] = true;
$sugar_config['external_cache_disabled_redis'] = true;
$sugar_config['external_cache_disabled_smash'] = true;
$sugar_config['external_cache_disabled_zend'] = true;
4. Save config_override.php and hit a quick rebuilt and repair.

5. Restart your webserver (mine is IIS 7.5)
6. To see if it’s installed correctly run a php_info(); and find this entry:

Name:  memcache_php.JPG
Views: 18
Size:  45.0 KB

7. To see if the pair server-client is working correctly open CMD and run netstat -n and you should see connections going from your client (SugarCRM) from a random port to your server (Memcached) to port 11211
8. Done !! 

I think Memcached it’s a great add to any SugarCRM installation and with wincache (only opcode caching) it helped to speed up considerably my Sugar instance especially under load (I have around 80 users).

Let me know your considerations and if you have any troubles and/or suggestions.

Matteo

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s