Installation Environment
Windows 7 64bit
Apache-tomcat-8.0.9-windows-x64
Solr-4.9.0
JDK 1.8.0_05 64bit
Installation Steps
The installation of Tomcat and JDK is skipped here.
Note: solr4.9 requires jdk1.7+
Step One:
Unzip solr-4.9.0 to any folder, I unzipped to D:\Installed applications\solr-4.9.0\solr-4.9.0 directory.
Step Two:
Copy the solr-4.9.0\dist\ Solr-4.9.0.war to the Tomcat webapp/directory, preferably renamed to Solr.war.
Step Three:
Start Tomcat, will error, this step is just to extract Solr-4.9.0.war, so manual decompression in the WebApp directory is also feasible.
Step Four:
Method One:
Open Webapps\solr\web-inf\web.xml
Found it:
<!--<env-entry> <env-entry-name>solr/home</env-entry-name> < Env-entry-value>/put/your/solr/home/here</env-entry-value> <env-entry-type> java.lang.string</env-entry-type></env-entry> --
Here is the need to configure solr/home, only need to modify <env-entry-value>/put/your/solr/home/here</env-entry-value>
This directory can be customized, it is recommended to use one of the steps to extract the directory, here need to be very careful: in the tutorial of the SOLR official website has the following paragraph:
How SOLR Works with Tomcat
The both basic steps for running SOLR in any WEB application container is as follows:
- Make the SOLR classes available to the container. In many cases, the SOLR WEB application Archive (WAR) file can is placed into a special directory of the application Conta Iner. In the case of Tomcat, you need to place the SOLR WAR file in Tomcat ' s WebApps directory. If you installed Tomcat with SOLR, take a look in tomcat/webapps:you ' ll see the Solr.war file is already there.
- Point SOLR to the SOLR home directory, that contains Conf/solrconfig.xml and Conf/schema.xml. There is a few ways to get the This is done. One of the best was to define the Solr.solr.home Java system property. With Tomcat, the best-of-the-environment variable, java_opts, is via a shell. Tomcat puts the value of this variable in the command line upon startup
From here you can see that the directory that,<env-entry-value> points to needs to contain the two files of Conf/solrconfig.xml and Conf/schema.xml, which means the <env-entry-value> The directory pointed to the need to have CONF subdirectory, I just because of this section of the official website explanation, engaged in a half-day without success, in fact, I understand the wrong, I think in the Solr.solr.home directory must have subdirectories conf,conf contains Solrconfig.xml and Schema.xml. But in fact, the Conf directory is placed under the Collection1 directory, collection is a instance instance of SOLR, SOLR can be configured with multiple collection, can have a separate configuration file.
My side of Web. XML is configured as:
<Env-entry><env-entry-name>solr/home</env-entry-name><env-entry-value>d:/ Installed applications/solr-4.9.0/solr-4.9.0/example</env-entry-value>< Env-entry-type>java.lang.string</env-entry-type></env-entry>
It is important to note that the configuration uses the backslash "/" instead of the default "\" under Windows.
Here I am pointing directly to the example folder.
Method Two ( personal recommendation ) :
Create a new Solr.xml file in the $tomcat_home/conf/catalina/localhost directory with the content:
<ContextPath= "/SOLR"DocBase= ".../tomcat/webapps/solr.war"Debug= "0" Crosscontext= " True "> <name= "Solr/home" Type=" java.lang.String " Value=" d:/installed applications/solr-4.9.0/ Solr-4.9.0/example " Override=" true "/> this way, you need to be aware that override needs to be set to false, otherwise each boot Tomcat will re-unzip the war file to overwrite the previous configuration, or manually unzip the context Path points directly to the folder
</context >
Step Five:
Copy the Collection1 directory in the SOLR-4.9.0\EXAMPLE\SOLR directory to the Solr-4.9.0\example directory as a whole. Readers can customize the path themselves, the <env-entry-value></env-entry-type> defined in Web. XML, and the directory containing the Collection1 directory is OK.
Step Six:
Copy the jar package from the D:\Installed Applications\solr-4.9.0\solr-4.9.0\example\lib\ext directory to the Apache-tomcat-8.0.9\lib directory. You can also copy to Webapps\solr\web-inf\lib, readers can choose their own (global and local problems only). (If you start or error, you can follow the prompts to find the appropriate jar package in solr-4.9.0\dist).
Step Seven:
Open the Tomcat conf directory under Server.xml, find the following snippet of code to add uriencoding= "UTF-8" and add Chinese support.
<Port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport = "8443" uriencoding/>
Step Eight:
Launch Tomcat, open browser input: http://localhost:8080/solr/admin/, see the splash screen to indicate that the installation was successful.
Summary
As can be seen from the above installation steps, step four is the most central step, which needs to understand how SOLR works: SOLR is a service similar to the HTTP interface, it needs to be deployed in the Web container (this is Tomcat), after running, Applications interact with SOLR in the same way as HTTP requests, including adding indexes, queries, and so on. So we need to deploy SOLR in the Web container, and specify the directory for the SOLR configuration in the Tomcat configuration.
The installation method under Linux does not differ greatly from Windows.
SOLR installation under Windows