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

Want to support HowtoForge? Become a subscriber!
 
Submitted by luisfreitas (Contact Author) (Forums) on Fri, 2011-03-18 14:13. :: Debian | SuSE

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
</IfModule>

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
extension=uploadprogress.so
extension=apc.so
extension=solr.so

Save your file and restart webserver:

/etc/init.d/apache2 restart

cd /tmp
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org/lucene/solr/1.4.1/apache-solr-1.4.1.zip
unzip apache-solr-1.4.1.zip
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):

http://yourwebsite.com:8983/solr/admin/

TEST OK!

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

SOLR_DIR="/usr/share/apache-solr/example"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java"

case $1 in
    start)
        echo "Starting Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS 2> $LOG_FILE &
        ;;
    stop)
        echo "Stopping Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS --stop
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac

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. 

http://yourdomain.com:8983/solr/admin/

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

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Wed, 2011-08-24 21:17.

It is stated in the beginning of the instructions to use ispconfig 2.  Does this mean that this will not work with ispconfig 3?  It would be very useful  to know whether this works for ispconfig 3 as well.  Does anyone know?

Thanks,

Thomas

Submitted by robertkein (not registered) on Wed, 2011-09-28 17:29.
I`ve just set up SOLR for my personal server with ISPconfig3 running, but had to use a lots of different manuals, because of my server`s Debian package was in minimal configuration.