Steps to configure Solr on Windows with Liferay
I have configured Solr for below environment
> apache-solr-1.4.1
> apache-tomcat-7.0.47
> liferay-portal-6.1.20-ee-ga2
1) Download Apache Solr 1.4.1
2) Unzip downloaded .zip file on the location D:/runtime/apache-solr-1.4.1
3) Copy war file D:/runtime/apache-solr-1.4.1/dist/apache-solr-1.4.1.war to D:/runtime/apache-solr-1.4.1/example/solr
4) Go to the location D:/runtime/apache-solr-1.4.1/example/solr/conf/
5) Open file "solrconfig.xml" from above location
6) Search for the tag "<dataDir>${solr.data.dir: ./solr/data}</dataDir>"
7) Replace the above tag like below
"<dataDir>${solr.data.dir:D:/runtime/apache-solr-1.4.1/example/solr/data}</dataDir>"
(This is the data folder where all the solr indexes will be created)
Lets run the solr instance on the plain apache tomcat instance
(In our case it is "apache-tomcat-7.0.47")
1) Extract the "apache-tomcat-7.0.47" on the location "D:\bundle\solr"
2) Create a below folder structure if not already available
D:\bundle\solr\apache-tomcat-7.0.47\conf\Catalina\localhost
3) Create a file on above path with the name "solr.xml"
4) Add below content inside "solr.xml" file
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="D:/runtime/apache-solr-1.4.1/example/solr/apache-solr-1.4.1.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="D:/runtime/apache-solr-1.4.1/example/solr" override="true"/>
</Context>
5) Start tomcat to monitor logs. Make sure that there are no logs available.
You should see below message under logs to make sure that server is started properly.
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\examples
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\host-manager
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\manager
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\ROOT
Nov 07, 2014 4:21:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Nov 07, 2014 4:21:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4928 ms
6) Confirm from browser that server is working properly
7) Hit "http://localhost:8080/solr/"
8) You should see below message in browser
Welcome to Solr!
Solr Admin
9) If you are able to see above message, congratulations we are done with solr setup
Now, lets see the steps to integrate solr with Liferay.
1) Extract "liferay-portal-6.1.20-ee-ga2" to the location "D:\bundle\solr"
2) Download solr plugin from net in my case it is as below
15187207_18881208_18881218.lpkg
(Make sure that it is compatible with your Liferay)
3) Put the solr plugin in the location "D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\deploy
4) Go to the location D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\conf
5) Open server.xml file to change the port (Need to change as tomcat is already using default ports)
Change below ports:
> <Server port="9005" shutdown="SHUTDOWN"> from <Server port="8005" shutdown="SHUTDOWN">
> <Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
from
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
> <Connector port="9009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
from
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
6) Start the liferay tomcat server
7) Monitor tomcat logs for exceptions if any
8) You should see below message in tomcat to make sure that tomcat is started successfuly
Nov 7, 2014 10:52:56 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Nov 7, 2014 10:52:56 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9080"]
Nov 7, 2014 10:52:56 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-9009"]
Nov 7, 2014 10:52:56 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 45386 ms
9) Shutdown both the servers
> apache-tomcat-7.0.47
> liferay-portal-6.1.20-ee-ga2
10) Go to the location D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\webapps\solr-web\WEB-INF\classes\META-INF
11) Open file "solr-spring.xml"
12) Search for the tag <bean id="com.liferay.portal.search.solr.server.BasicAuthSolrServer"
(Replace the constructor-argument as below "<constructor-arg type="java.lang.String" value="http://localhost:8080/solr" />")
13) Go to the location "D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\webapps\solr-web\WEB-INF\conf"
14) Copy the file "schema.xml"
15) Go to the location D:\runtime\apache-solr-1.4.1\example\solr\conf
16) Paste the "schema.xml" file in this location (Need to overwrite file)
17) Start "apache-tomcat-7.0.47" server, once it is up then start "liferay-portal-6.1.20-ee-ga2"
18) Go to the Liferay Control panel -> Server Administration -> Resources
19) Click on the "Reindex all search indexes"
20) Indexes will be generated on the path "D:\runtime\apache-solr-1.4.1\example\solr\data"
We are done with integration of liferay with solr.
Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics
I have configured Solr for below environment
> apache-solr-1.4.1
> apache-tomcat-7.0.47
> liferay-portal-6.1.20-ee-ga2
1) Download Apache Solr 1.4.1
2) Unzip downloaded .zip file on the location D:/runtime/apache-solr-1.4.1
3) Copy war file D:/runtime/apache-solr-1.4.1/dist/apache-solr-1.4.1.war to D:/runtime/apache-solr-1.4.1/example/solr
4) Go to the location D:/runtime/apache-solr-1.4.1/example/solr/conf/
5) Open file "solrconfig.xml" from above location
6) Search for the tag "<dataDir>${solr.data.dir: ./solr/data}</dataDir>"
7) Replace the above tag like below
"<dataDir>${solr.data.dir:D:/runtime/apache-solr-1.4.1/example/solr/data}</dataDir>"
(This is the data folder where all the solr indexes will be created)
Lets run the solr instance on the plain apache tomcat instance
(In our case it is "apache-tomcat-7.0.47")
1) Extract the "apache-tomcat-7.0.47" on the location "D:\bundle\solr"
2) Create a below folder structure if not already available
D:\bundle\solr\apache-tomcat-7.0.47\conf\Catalina\localhost
3) Create a file on above path with the name "solr.xml"
4) Add below content inside "solr.xml" file
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="D:/runtime/apache-solr-1.4.1/example/solr/apache-solr-1.4.1.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="D:/runtime/apache-solr-1.4.1/example/solr" override="true"/>
</Context>
5) Start tomcat to monitor logs. Make sure that there are no logs available.
You should see below message under logs to make sure that server is started properly.
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\examples
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\host-manager
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\manager
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\bundle\solr\apache-tomcat-7.0.47\webapps\ROOT
Nov 07, 2014 4:21:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Nov 07, 2014 4:21:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Nov 07, 2014 4:21:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4928 ms
6) Confirm from browser that server is working properly
7) Hit "http://localhost:8080/solr/"
8) You should see below message in browser
Welcome to Solr!
Solr Admin
9) If you are able to see above message, congratulations we are done with solr setup
Now, lets see the steps to integrate solr with Liferay.
1) Extract "liferay-portal-6.1.20-ee-ga2" to the location "D:\bundle\solr"
2) Download solr plugin from net in my case it is as below
15187207_18881208_18881218.lpkg
(Make sure that it is compatible with your Liferay)
3) Put the solr plugin in the location "D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\deploy
4) Go to the location D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\conf
5) Open server.xml file to change the port (Need to change as tomcat is already using default ports)
Change below ports:
> <Server port="9005" shutdown="SHUTDOWN"> from <Server port="8005" shutdown="SHUTDOWN">
> <Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
from
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
> <Connector port="9009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
from
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
6) Start the liferay tomcat server
7) Monitor tomcat logs for exceptions if any
8) You should see below message in tomcat to make sure that tomcat is started successfuly
Nov 7, 2014 10:52:56 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Nov 7, 2014 10:52:56 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9080"]
Nov 7, 2014 10:52:56 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-9009"]
Nov 7, 2014 10:52:56 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 45386 ms
9) Shutdown both the servers
> apache-tomcat-7.0.47
> liferay-portal-6.1.20-ee-ga2
10) Go to the location D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\webapps\solr-web\WEB-INF\classes\META-INF
11) Open file "solr-spring.xml"
12) Search for the tag <bean id="com.liferay.portal.search.solr.server.BasicAuthSolrServer"
(Replace the constructor-argument as below "<constructor-arg type="java.lang.String" value="http://localhost:8080/solr" />")
13) Go to the location "D:\bundle\solr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\webapps\solr-web\WEB-INF\conf"
14) Copy the file "schema.xml"
15) Go to the location D:\runtime\apache-solr-1.4.1\example\solr\conf
16) Paste the "schema.xml" file in this location (Need to overwrite file)
17) Start "apache-tomcat-7.0.47" server, once it is up then start "liferay-portal-6.1.20-ee-ga2"
18) Go to the Liferay Control panel -> Server Administration -> Resources
19) Click on the "Reindex all search indexes"
20) Indexes will be generated on the path "D:\runtime\apache-solr-1.4.1\example\solr\data"
We are done with integration of liferay with solr.
Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics