Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

How To Install Apache-Solr And Use It With Drupal And ISPConfig (OpenSUSE/Debian)

Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, and rich document (e.g., Word, PDF) handling. I use this on OpenSUSE and Debian (minor tweaks on Debian, just paths to correct but it’s almost the same). Packages from 4 of March 2011.

Search On Steroids

Install Drupal. And use ISPConfig 2.

Use this .htacess file in the root of your Drupal installation:

<IfModule mod_rewrite.c>  
RewriteEngine on
#RewriteBase /  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]  
#RewriteCond %{REQUEST_URI} !=/favicon.ico

Alter the .htacess file in /web/sites/default/files and comment:

#SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
#Options None

Install Drupal. This tutorial doesn’t cover full Drupal installation.

Log in as root or sudo as you wish.

Install some dependencies Drupal needs:

pecl install uploadprogress
pecl install json
pecl install apc
pecl install -n solr-beta

Also install Java 1.5 (gives error if 1.6) on your server. (This tutorial doesn’t cover Java installation.)

Open your php.ini

nano -w /etc/php5/apache2/php.ini

… and paste the following extensions uploadprogress, apc and solr so the extensions load with PHP:

; Directory in which the loadable extensions (modules) reside.
extension_dir = /usr/lib64/php5/extensions

Save your file and restart webserver:

/etc/init.d/apache2 restart

cd /tmp
mv apache-solr-1.4.1 apache-solr
cp -r apache-solr /usr/share/apache-solr

Copy configuration from your Drupal installation, in my case /srv/www/web11/web:

cp /srv/www/web11/web/sites/all/modules/apachesolr/solrconfig.xml /usr/share/apache-solr/example/solr/conf/solrconfig.xml
cp /srv/www/web11/web/sites/all/modules/apachesolr/schema.xml /usr/share/apache-solr/example/solr/conf/schema.xml

cd apache-solr/example
java -jar start.jar

In your browser, test it (remember to open in ISPConfig firewall port 8983):


ctrl+c in your terminal and apache-solr ends… But never mind.

Let’s make a start script so it starts solr when system boots:

nano -w /etc/init.d/solr

And paste this script:

#!/bin/sh -e

# Starts, stops, and restarts solr

JAVA_OPTIONS=”-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar”

case $1 in
echo “Starting Solr”
echo “Stopping Solr”
$0 stop
sleep 1
$0 start
echo “Usage: $0 {start|stop|restart}” >&2
exit 1

Make it executable:

chmod a+rx /etc/init.d/solr

Check what is booting:

chkconfig –list

Oh no! solr is not booting. Of course not!

chkconfig –add solr

Then try to stop it:

service solr stop

Oh. It’s not working? Let’s try to start it:

service solr start

Test on your browser.

It’s ALIVE! apache-solr, search on steroids!

Now you can reboot your server, too, and see apache-solr working. 🙂