Use the search_api_solr Module with OpenAtrium and Apache Solr on Debian Wheezy
If you have set up the latest search_api_solr Module with OpenAtrium and want to use Apache Solr on Debian Wheezy here is my way to do it. I have tried to make the latest Solr 4.x work a few times without success. So i decided to use the latest 3.x version of solr and it worked smoothly. To make it start automatically on reboot this is the way to make it work:
Downloads you need for this tutorial:
http://archive.apache.org/dist/lucene/solr/3.6.2/apache-solr-3.6.2.zip
#!/bin/bash
1.extract the zip file to a directory outside of yout webroot directory and jump into it:
unzip apache-solr-3.6.2.zip
cd /apache-solr-3.6.2/example
2.Check if Java is installed and manually start Solr
which java
/usr/bin/java
3. Install Daemon on Linux
sudo apt-get install daemon
4. Copy the following files into the solr conf directory and before that delete the exisiting ones there
cd /solr/apache-solr-3.6.2/example/solr/conf
sudo rm -rf elevate.xml mapping-ISOLatin1Accent.txt protwords.txt schema_extra_fields.xml schema_extra_types.xml schema.xml solrconfig_extra.xml solrconfig.xml solrcore.properties stopwords.txt synonyms.txt
cd /openatrium/profiles/openatrium/modules/contrib/search_api_solr/solr-conf/3.x
sudo cp elevate.xml mapping-ISOLatin1Accent.txt protwords.txt schema_extra_fields.xml schema_extra_types.xml schema.xml solrconfig_extra.xml solrconfig.xml solrcore.properties stopwords.txt synonyms.txt /apache-solr-3.6.2/example/solr/conf
5. Try to start Solr
cd /apache-solr-3.6.2/example
/usr/bin/java -jar start.jar
If that is a success go on with these steps
6. Create a directory for the solr logfile and create solr.log there
sudo mkdir /var/log/solr/
sudo vi solr.log
7.Create the startup script /etc/init.d/solr and copy this code into that file: sudo vi /etc/init.d/solr
########################## Script Start ########################################
<code>#!/bin/sh
start () {
echo -n "Starting solr..."
# Start daemon
daemon --chdir='/apache-solr-3.6.2/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
NAME=solr
PIDFILE=/var/run/.pid
### BEGIN INIT INFO
# Provides: solr
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
RETVAL=$?
if [ = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return
}
stop () {
# Stop daemon
echo -n "Stopping solr..."
daemon --stop --name=solr --verbose
RETVAL=$?
if [ = 0 ]
then
echo "Done."
else
echo "Failed. See error code for more information."
fi
return
}
restart () {
daemon --restart --name=solr --verbose
}
status () {
# Report on the status of the daemon
daemon --running --verbose --name=solr
return $?
}
case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit </code>
########################## Script End ########################################
8. Add Solr to the Services Config
chkconfig --add solr
9. Reboot your server and test if Solr is running
/etc/init.d/solr start
10. Check if Solr is running
/etc/init.d/solr status
daemon: solr is running (pid 3698)
11. Now login to your OpenAtrium installation and test if solr is recognized as a running service
domain.tld/admin/reports/status
Solr servers 1 server
The Solr server could be reached.
Enjoy!