How to install memcache on windows

Check your operating system whether 32bit or 64 bit. Based on that you need to download the binary version.

  1. 64bit Os – http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip

  2. 32bit Os – http://code.jellycan.com/memcached/

  • Place the binary file on C or D location
  • Now Run the Command Prompt as Administrator – type the cmd –  C:/memcached/memcached.exe  -d install
  • Once Installed, Start the service – C:\memcached\memcached.exe -d start
  • Verify the service running properly on Start- > Run -> services.msc
  • Check your php extensions directory for php_memcache.dll
  • If you don’t have it, Download http://pecl.php.net/package/memcache/3.0.8/windows
  • Now Edit the Php.ini file and add following lines at extension section
  1. extension=php_memcache.dll
  2. Restart your apache server and Now we are good go.

If you are using Drupal then add below lines to settings.php

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

you can check the memcahce settings at “admin/reports/memcache”

 

If you are using Core php then use below code for checking memcache working or not.

<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
?>
Advertisements

ApacheSolr Configuration in Ubuntu for Drupal

NOTE:  For installing Apache Solr with Drupal on a Windows machine, pls use following link for the setup http://drupal.org/node/532584; instead of the instructions below. Also see the comments on this link, if you face any issues.

Installing Tomcat
sudo apt-get install tomcat7 tomcat7-admin tomcat7-common tomcat7-user tomcat7-docs tomcat7-examples

Start tomcat by typing
  sudo /etc/init.d/tomcat7 start

Security (Not required if installing on same machine)
If you are using ip-tables and installing Apache Solr on an external server,
modify or add the following line to accept the port 8080
-A INPUT -p tcp -m tcp –dport 8080 -j ACCEPT

After installation type http://localhost:8080 or http://serverip:8080 in your browser.Now you should see tomcat welcome page.

Install Solr
(Check for latest version or nightly build on http://apache.rediris.es/lucene/solr/ orhttp://people.apache.org/builds/lucene/solr/nightly)
wget http://apache.rediris.es/lucene/solr/1.4.1/apache-solr-1.4.1.tgz

unzip apache-solr-1.4.1.tgz
       tar -zxvf apache-solr-1.4.1.tgz

Linking tomcat7 with Apache Solr application

mkdir /usr/share/tomcat7/webapps

This should give you an idea on where your distribution installed tomcat7.
Attention : If your path is different do not forget to also adjust this in the next steps. whereis tomcat7

should show you tomcat7: /etc/tomcat7 /usr/share/tomcat7

copy the war file to the webapps directory

sudo cp apache-solr-1.4.1/dist/apache-solr-1.4.1.war /usr/share/tomcat7/webapps/solr.war

copy the example solr application to a new directory called solr. We will change this example solr application later on to be viable for Drupal 6

sudo cp -R apache-solr-1.4.0/example/solr/ /usr/share/tomcat7/solr/
create our config file
 sudo nano /etc/tomcat7/Catalina/localhost/solr.xml
And fill it with the following configuration :
 <Context docBase="/usr/share/tomcat7/webapps/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/tomcat7/solr" override="true" />
  </Context>
Managing tomcat7 application
 We want to see how and/or if our Solr application is running, we can do this by using the manager application. By default you don't have access to this application so we have to modify the permissions.
     sudo nano /etc/tomcat7/tomcat-users.xml

And modify it so it more or less reflects the same information as shown here.

<tomcat-users>
  <role rolename="admin"/>
  <role rolename="manager"/>
  <user username="nick" password="ateneatech" roles="admin,manager"/>
  </tomcat-users>
Drop Tomcat security so Solr can access /usr/share/tomcat7/solr
          sudo nano /etc/default/tomcat7
And modify it so our security is disabled. Be careful if you are running on a server which you do not control 100%!
     tomcat7_SECURITY=no
restart our tomcat service
       sudo /etc/init.d/tomcat7 restart

surf to http://localhost:8080/manager/ and log in with your username and password from above and check if the solr instance is started. If not start and it and check wether or not you receive an error code!
If your application is started, surf to http://localhost:8080/solr/admin and you should see a nice screen!

Linking Drupal 6 with a running Apache Solr
Perform this step if you do not have apache-solr module already enabled i.e. you are adding apache-solr to your app for the first time:

I assume you have Drush installed so we continue with downloading the apachesolr module. Execute this commando in the designated website.
drush dl apachesolr

Perform following steps for all installations of apache solr:
 let's copy our schema that will customize our Apache Solr Instance so it fits the "Drupal" bill.
 sudo cp apachesolr/schema.xml /usr/share/tomcat7/solr/conf/schema.xml

 sudo cp apachesolr/solrconfig.xml /usr/share/tomcat7/solr/conf/solrconfig.xml

Tip: it might be a good idea to use symbolic links so we can easily update our modules and update our schemes if they change …you never know with open source 😉

Additional : give the folder permissions!
 sudo chown -R tomcat7:root /usr/share/tomcat7/solr/

Enable the module in the modules list and go to the config screen fill in the next parameters:

Host name of your Solr server, e.g. localhost or IP Address or example.com
Solr host name: localhost

Port on which the Solr server listens. Tomcat is 8080 by default.
Solr port: 8080

Path that identifies the Solr request handler to be used.
Solr path: solr

On saving these settings, message “Your site has contacted Apache Solr” will be displayed.
You can now start indexing the existing content on your site using cron and check the amount of indexing done at “admin/settings/apachesolr/index”