ubuntu下安装solr

1.安装jdk软件

2.安装tomcat

   (1)下载tomcat软件,将其解压到/usr/local下

 	sudo tar -zxvf apache-tomcat-7.0.59.tar.gz -C /usr/local

   (2) 设置环境变量,在path路径后加:CATALINA_HOME=/usr/local/apache-tomcat-7.0.59

	sudo gedit /etc/environment 

 (3) 进入/usr/local/apache-tomcat-7.0.59/bin后,打开catalina.sh文件,在文件末尾添加

	sudo cd /usr/local/apache-tomcat-7.0.59/bin
	sudo gedit catalina.sh

在文件末尾添加

CATALINA_HOME=/usr/local/apache-tomcat-7.0.59

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67

   (4)启动tomcat

	sudo ./startup.sh

3.安装Solr

(1)下载Solr,将其解压,将解压后文件夹里中example/solr作为solr根目录放到/usr/local下

	sudo tar -zxvf solr-4.10.2.tgz
	sudo cp -r ./solr-4.10.2/example/solr  /usr/local

  (2)复制example/lib/ext中的jar文件到apache-tomcat-7.0.59/lib下,复制example/resources中的log4j.properties文件到apache-tomcat-7.0.59/lib

	sudo cp -r ./solr-4.10.2/example/lib/ext /usr/local/apache-tomcat-7.0.59/lib
	sudo cp -r ./solr-4.10.2/example/resources /usr/local/apache-tomcat-7.0.59/lib

(3)复制example/dist/solr-4.10.2.war 到apache-tomcat-7.0.59/webapps下

sudo cp ./solr-4.10.2/example/dist/solr-4.10.2.war /usr/local/apache-tomcat-7.0.59/webapps/solr.war

(4)进入/usr/local/solr,创建data文件夹,并给予data读写的权限

	sudo cd /usr/local/solr
	sudo mkdir data
	sudo chmod a+w data

(5)编辑/usr/local/solr/collection1/conf/solrconfig.xml,将

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

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

	sudo gedit /usr/local/solr/collection1/conf/solrconfig.xml

(6)在/usr/local/apache-tomcat-7.0.59/conf/Catalina/localhost文件夹下新建文件solr.xml

	sudo gedit /usr/local/apache-tomcat-7.0.59/conf/Catalina/localhost/solr.xml
添加也下内容:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/usr/local/apache-tomcat-7.0.59/webapps/solr.war" debug="0" crossContext="true"> 
<Environment name="solr/home" type="java.lang.String" value="/usr/local/solr" override="true" />
</Context>
注意:检查文件格式是否正确,如果浏览器打开solr.xml能正常打开,则格式正确

(7)重启tomcat,在apache-tomcat-7.0.59/webapps下会增加一个solr目录,之后修改webapps/solr/WEB-INF/web.xml文件,将

<!--

    <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>

 –->

修改为

    <env-entry>

       <env-entry-name>solr/home</env-entry-name>

       <env-entry-value>/usr/local/solr</env-entry-value>

       <env-entry-type>java.lang.String</env-entry-type>

               </env-entry>

	sudo cd /usr/local/apache-tomcat-7.0.59/bin
	sudo ./shutdown.sh
	sudo ./startup.sh
	sudo gedit /usr/local/apache-tomcat-7.0.59/webapps/solr/WEB-INF/web.xml

(8)重启tomcat,之后浏览器输入http://localhost:8080/solr



你可能感兴趣的:(tomcat,ubuntu,Solr)