User account menu

  • Log in
BXTra.net

Breadcrumb

  • Home
  • Articles
  • Install Apache Solr on Drupal + CentOS

Install Apache Solr on Drupal + CentOS

By BXTra | 8:43 PM PST, Thu March 03, 2011
Drupal
CentOS

1. Install Java SDK using below command :

yum install java-1.6*

2. Download Apache Solr module from Drupal server. (Do it as you normally do with Drupal)

3. Then, get "SolrPhpClient" and put it under Apache Solr module directory. The directory name must be "SolrPhpClient".

wget http://solr-php-client.googlecode.com/files/SolrPhpClient.r22.2009-11-09.zip

4. Download the latest Solr 1.4.x release (Current is 1.4.1). Below, I put it in root directory. You can put it anywhere but not where you can access it through your website. So, not under "public_html" folder. I also renamed folder to make it shorter.

cd /
wget http://mirror.tourismthai.org/apache//lucene/solr/1.4.1/apache-solr-1.4.1.tgz
tar xvfz apache-solr-1.4.1.tgz
mv apache-solr-1.4.1 solr

5. Apache Solr comes with an example files you can use and they are located as a subdirectory in ApacheSolr folder. So, what you have to do is to copy 2 files ( schema.xml and solrconfig.xml ) from Apache Solr Drupal module directory to replace files in "/solr/example/solr/conf" folder

cp ../public_html/sites/all/modules/apachesolr/schema.xml /solr/example/solr/conf
cp ../public_html/sites/all/modules/apachesolr/solrconfig.xml /solr/example/solr/conf

6. To test if Apache Solr is working try below command :

cd /solr/example
java -jar start.jar

Now, try to access your Apache Solr page with below URL :

http://localhost:8983/solr/admin/

You may replace "localhost" to your own "IP Address". If you saw an Apache Solr page, then, it's working. If not, make sure you don't have any firewall to block port 8983. After you're done setting it, you can block port 8983 as usual. Since you don't need to open your firewall to access localhost. If Apache Solr is running, you will see something similar to image below :


7. Try to enable Apache Solr Module in your Drupal. It should work now.

8. Now, I'm sure you don't want to run "java -jar start.jar" everytime you reboot your server. So, you have to create Start/Stop script to make it automatically startup when reboot. So, follow steps below :

Create Apache Solr Start/Stop Script

nano -w /etc/init.d/solr


Copy and paste code below :

Apache Solr Start/Stop Script

#!/bin/sh -e

# Starts, stops, and restarts solr
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr

SOLR_DIR="/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

Above is the startup script. What you really need to change is line #7 which is the path to your Apache Solr file.

You may also need to look at line #8. "-Xmx1024m" is to set maximum memory allowed to use in Java. Here, I set it to 1 gigabyte (= 1,024 megabytes). Lower it if you don't have that much RAM or increase it if Apache Solr needs more RAM.

Once you are done with it. run

chmod 755 /etc/init.d/solr

Now, you can start stop or restart Apache Solr with below command :

service solr start
service solr stop
service solr restart

To make it run automatically, run below command :

sudo chkconfig --add solr


Software :
- CentOS 5.4 - 64 bits
- Apache Solr 1.4.1
- OpenJDK though Yum package
- Drupal 6.20
- Apache Solr module 1.2 for Drupal

Source :
- http://drupalcode.org/project/apachesolr.git/blob/HEAD:/README.txt
- http://19thstreetdesign.com/blog/2009.02.04/installing-apache-solr-drupal-6
- http://drupal.org/node/545368

Update : 2011.07.25 - Tested with Apache Solr 3.3 and it works using the same instruction.

About text formats
  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Donald

14 years 2 months ago

Permalink

Great post worked perfectly!

Great post worked perfectly! Thanks!
  • Reply

Arie

14 years ago

Permalink

giving it a try

Some other articles didn't work, no trying yours!
  • Reply

Arie

14 years ago

Permalink

In reply to giving it a try by Arie

thanks

it worked!
  • Reply

Geoffrey

13 years 10 months ago

Permalink

Tnx

Works like a charm.. Even with Solr 3.3. Thx!!! In addition off this guide -> also visit http://acquia.com/blog/use-apache-solr-search-files
  • Reply

Luis

12 years 5 months ago

Permalink

Problem Not_found

hi, i have a problem when i create the solr script , after that I go to localhost:8983/solr and show me HTTP ERROR: 404 Problem accessing /solr. Reason: NOT_FOUND pleasee, help mee!
  • Reply

Evelin

12 years 4 months ago

Permalink

UwTgAyEKKLKatZdjWi

Hi,Nice trick but for me it is not working. I am using dupal 6.x and try to use your code in my moulde. let me explain what am i exactly doing so you might help me. in my moulde i am creating one database and after that fetching values from .sql file and trying to insert it into newly created database. Now with my moulde i have made one database but to insert new query in that database i have to switch db and run query. When i try to use your trick it simple give me error that Access denied for moulde and logout from website. can you help me ? you can directly email me also if you have some solution.

  • Reply

Torsten Zenk

12 years 3 months ago

Permalink

Tested on Debian Squeeze with Apache Solr 3.6.2 and Drupal 7.19

works great!!! Thank you very much!

  • Reply
  • Add new comment

  • Will the router get the Openvpn as a client option?
    6 years ago
  • cancellation
    6 years 1 month ago
  • Router ASUS RT-N12 D1 tomatoes passwort falsch
    7 years 8 months ago
  • WPS button = 30/30/30 hard reset button
    7 years 9 months ago
  • Save my day!
    8 years 3 months ago
  • How to
    8 years 6 months ago
  • Can i still access my modem (the one with the ISP provided)?
    8 years 6 months ago
  • A saving step!
    8 years 10 months ago
  • Problem with Asus n12e-c1
    8 years 11 months ago
  • don't use Hostgator
    9 years 2 months ago

© 2007 - 2023 BXTra.net. All Rights Reserved. 
Certain other content, photos and artwork displayed on BXTra.net are protected by copyright and are the property of their respective owners.

Privacy Policy