How to run Solr 4 in Tomcat locally?

后端 未结 6 1112
[愿得一人]
[愿得一人] 2021-02-07 09:58

I\'ve been trying to set up Solr 4.3 on my home PC (in Tomcat 7) but it doesn\'t run. I have set up Tomcat and deployed the solr.war file which both unpacks and sho

6条回答
  •  梦毁少年i
    2021-02-07 10:19

    I had some problem doing the same thing, the official documentation is not really helpful about this. I wrote a blog post about it which reads:

    1. Solr install

      Download and unpack the latest version of Solr, somewhere on the disk.

      cd /tmp
      wget "http://mirrors.ircam.fr/pub/apache/lucene/solr/4.6.0/solr-4.6.0.tgz"
      cd /opt
      sudo tar zxvf /tmp/solr-4.6.0.tgz
      sudo chown -R tomcat:tomcat solr-4.6.0
      

      Here, I use /opt, but you can install it anywhere as long as Tomcat has access to it. Just to be sure, make Tomcat the owner, so it can read and write in Solr folders.

    2. Deployment

      Now, let's deploy the Solr webapp on Tomcat. To do so, we will take advantage of an XML context configuration file, wich we will use to deploy and configure Solr.

      In your Tomcat installation folder, create a new XML context configuration file in conf/Catalina/localhost. The base name of the file will define the Solr context path.

      We first need to define ${solr.home}. Here, we use the example Solr configuration provided in the distribution. It is located in /opt/solr-4.6.1/example/solr.

      To avoid startup errors, we need to add some jars to the webapp classpath, located in /opt/solr-4.6.1/example/lib/ext. But we don't want to pollute Tomcat's lib folder with Solr jars, so we just declare a virtual loader.

      We also need to configure Log4J properly. Here we use the Log4J configuration file provided in Solr distribution in /opt/solr-4.6.1/example/resources, by adding the folder in Solr classpath.

      
      
        
        
      
      

      Save the file, wait for Tomcat to read it and deploy the war.

    That's it! Solr is up and running.

提交回复
热议问题