Thursday, March 6, 2014

Install memcache on moodle 2.4

So...this took me a stupidly long time to wrap my head around it. But I think I finally installed everything correctly. Even though Moodle 2.4+ supports caching through memcache, you first need to install it on your server.

ON YOUR SERVER
Hopefully you will be using WHM manager to have a nice interface when interacting with your server.

1)  Login to your WHM panel as the root user
2)  Go to "Easy Apache". Click through the screens until you get to the php setup page.
3)  Scroll down so you will see the "See Exhaustive Options" button. Click it.
4)  Now there are more options on the page. Simply search the page until you find "memcache." Check the option and save your configuration.
5)  Now you need to go into "Software -> Module Installers -> PHP Pecl". Click on the manage button so you option up the new options screen.
6)  Now you should see the area on the screen that says "Install php Pecl module" and an empty text box. Inside the box you can type "memcache" and/or "memcached".
7)  Click the "Install Now" button.
8)  Once the installation process is complete, you will need to restart apache. (Restart services -> HTTP (apache))

ON MOODLE
1)  Login to moodle as the administrator
2)  Go to "Site Administration -> Plugins ->Caching -> Configuration."
3)  You will come to a new page where you will see the caching options listed inside the first table on the top of the page. Inside the row that says "memcache", you should now see a new link in the right-most column that says "Add Instance." Click the link
4)  You will come to a new page where you configure which server should be memcached. In my case, it's the same server that I am hosting on.
5)  Name your file and enter the domain of your server like:   mydomain.com (you don't need the www in front).
        a)  I also needed to add the default port number to make this work. mydomain.com:11211
6)  Save your changes.
7)  Now you need to go into "Plugins ->Caching ->CacheStores ->Memcache." Enter the same domain like step #5 (mydomain.com:11211).
8)  Save your changes.
9)  On the "Plugins ->Caching -> Configuration,"  you will need to modify the other settings within those tables and map them to your new memcache store. Just like the right-most column that said "Add instance", the right-most column in the other tables are links. You need to "Edit" some of those columns and activiate your new memcache store to start loading things. Like the strings.
10)  Finally, you should go into "Plugins ->Caching ->Test Performance." The "result" column should say "tested" next to the memcache row. If it doesn't you didn't install it properly.



4 comments:

  1. Hi,
    I followed all the steps and I could see memcache enabled on my server when I check php Info page on my Moodle.
    Added instance as suggested in your article and also followed every step.
    But when I go to Test performance page I am seeing like this for memcache:
    "Memcache Store not ready"

    Can you please guide me

    Thanks
    Pramod
    India

    ReplyDelete
    Replies
    1. Hi I could find the solution.
      Memcached server was not running on my server.
      Memcache Store was ready after running Memcached server.

      Information to others:
      First Memcache extension for PHP has to be installed on server and then Memcached server has to be installed and run.

      Thanks
      Pramod

      Delete
  2. Thank you for sharing such useful information! memcached is a very powerful web application.
    regards,
    SEO melbourne

    ReplyDelete