Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Instructions

Install OpenJDK

sudo apt-get -y install openjdk-7-jdk
sudo mkdir /usr/java
sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default

Install Tomcat

sudo apt-get install tomcat7
sudo apt-get install tomcat7-admin

Install Solr

sudo wget http://archive.apache.org/dist/lucene/solr/4.8.1/solr-4.8.1.tgz
sudo tar -xvf solr-4.8.1.tgz 
sudo cp -R solr-4.8.1/example/ /opt/solr

Setup Solr with Tomcat

sudo cp -R /opt/solr/lib/ext/* /usr/share/tomcat7/lib/
sudo cp /opt/solr/webapps/solr.war /var/lib/tomcat7/webapps/solr.war
sudo cp -R /opt/solr /var/lib/tomcat7
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr
service tomcat7 restart

cd /var/lib/tomcat7/solr
sudo mkdir <my_collection>
cd <my_collection>
sudo mkdir data
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr

Setup Rails

cp <RAILS_ROOT>/solr/conf/schema.xml /var/lib/tomcat7/solr/<my_collection>
cp <RAILS_ROOT>/solr/conf/solrconfig.xml /var/lib/tomcat7/solr/<my_collection>

sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr
sudo service tomcat7 restart
### config/sunspot.yml
production:
solr:
hostname: localhost
port: 8080
log_level: WARNING
path: /solr/my_collection
# read_timeout: 2
# open_timeout: 0.5
@leandromoreira

This comment has been minimized.

Copy link
Owner Author

@leandromoreira leandromoreira commented Jan 23, 2015

THANK YOU VERY MUCH!!!

I would fix only:

cp <RAILS_ROOT>/solr/conf/schema.xml /var/lib/tomcat7/solr/<my_collection>
cp <RAILS_ROOT>/solr/conf/solrconfig.xml /var/lib/tomcat7/solr/<my_collection>

for

cp <RAILS_ROOT>/solr/conf/schema.xml /var/lib/tomcat7/solr/<my_collection>/conf/
cp <RAILS_ROOT>/solr/conf/solrconfig.xml /var/lib/tomcat7/solr/<my_collection>/conf/

I also needed to copy collection1 from solr/collection1 to root (/var/lib/tomcat7/solr)
cp -r solr/collection1/ .

And then I accessed ui localhost:8080/solr to add my core "Core Admin". In the end I also make it only available to localhost:

cd /var/lib/tomcat7/conf

And edit server.xml

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />

I added address to restrict access to only localhost.

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               address="127.0.0.1"
               redirectPort="8443" />

PS: I did that for my version of solr (solr-4.10.3) + tomcat7

and I also needed to add my core
curl "http://localhost:8080/solr/admin/cores?action=CREATE&name=production&instanceDir=production&config=solrconfig.xml&schema=schema.xml&dataDir=data&persist=true"

persist=truemakes the magic, otherwise every time you restar server you lost your core conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment