Skip to content

Instantly share code, notes, and snippets.

@milanchheda
Last active September 3, 2018 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save milanchheda/07cd7df1ad8721707cb2344b3f2ddc04 to your computer and use it in GitHub Desktop.
Save milanchheda/07cd7df1ad8721707cb2344b3f2ddc04 to your computer and use it in GitHub Desktop.
Installation of Apache solr 4.0 on Ubuntu 12.04 using Vagrant

Installation of Apache solr 4.0 on Ubuntu 12.04:

vagrant init hashicorp/precise64; vagrant up --provider virtualbox
vagrant up
vagrant ssh

Install Tomcat 6:

apt-get update
apt-get install tomcat6 tomcat6-admin

If above steps doesn't work for tomcat installation, try below steps:

apt-get install python-software-properties sudo add-apt-repository ppa:ferramroberto/java
apt-get install python-software-properties
apt-get install sun-java6-jdk sun-java6-plugin tomcat6 ant openjdk-6-jdk
apt-get update
apt-get install sun-java6-jdk sun-java6-plugin tomcat6 ant openjdk-6-jdk
apt-get install tomcat6 tomcat6-admin

Download and install Apache SOLR 4.0

wget http://archive.apache.org/dist/lucene/solr/4.0.0/apache-solr-4.0.0.tgz
tar -vxf apache-solr-4.0.0.tgz
mkdir /opt/solr
cp -r apache-solr-4.0.0/example/solr/* /opt/solr/
cp apache-solr-4.0.0/example/webapps/solr.war /opt/solr/
cp -r apache-solr-4.0.0/example/lib/ext/* /var/lib/tomcat6/shared/

Edit the Apache SOLR config file:

vi /opt/solr/collection1/conf/solrconfig.xml

Change the line "dataDir" by the following:

<dataDir>${solr.data.dir:/opt/solr/data}</dataDir>

Create the directory for the data and adjust access rights:

mkdir /opt/solr/data
chown tomcat6 /opt/solr/data/

Setup new context in tomcat pointing to our Solr files:

vi /etc/tomcat6/Catalina/localhost/solr.xml

Fill in the file with the information below:

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr" override="true"/>
</Context>

Restart tomcat:

/etc/init.d/tomcat6 restart

Hit http://SERVER-IP-ADDRESS:8080/solr/ and you should be able to see default Apache solr page.

@okankrblt
Copy link

i have an error like this.
cp: cannot stat 'apache-solr-4.0.0/example/lib/ext/*': No such file or directory

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