0

I've tried various tutorials and I get a 404 error when I finally navigate to host:port/solr on my CentOS machine.

Can anyone tell me why I would get a 404?

Once I find a solution I'll make this the official tutorial on how to install Apache Solr on a CentOS 6 / Tomcat6 configuration. In the meantime, there is very little documentation out there...


Tomcat6 Configuration (Source)

yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps

vi /usr/share/tomcat6/conf/tomcat6.conf
JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/"

Additionally, I've added an admin and manager role user in /etc/tomcat6/tomcat-users.xml


/usr/share/tomcat6/conf/Catalina/localhost/solr.xml

<Context docBase="/data/solr/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/data/solr" override="true" />
</Context>
AlxVallejo
  • 1,066
  • 4
  • 11
  • 19

1 Answers1

0

You must configure Tomcat to actually point to the Solr instance.

See Solr's example in their documentation:

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

This should be placed in $CATALINA_HOME/conf/Catalina/localhost/solr.xml, and adjust the paths for your install locations.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • This is awesome, and I'll def. accept this, but now I see that I'm getting a 500 error in my solr configuration. http://screencast.com/t/K9TKDqNI – AlxVallejo Feb 23 '12 at 17:38
  • It's trying to create the directory `/usr/share/tomcat/solr/data/index` and failing - what's your `solr/home` configured to be? – Shane Madden Feb 23 '12 at 17:41
  • 1
    @AlxVallejo, What user is running Tomcat? Make sure that user has permissions to the solr/home directory. – HTTP500 Feb 23 '12 at 17:49
  • @HTTP500, I simply created a new user in the tomcat-users.xml – AlxVallejo Feb 23 '12 at 18:05
  • @ShaneMadden, my solr/home is at /data/solr/ – AlxVallejo Feb 23 '12 at 18:06
  • @AlxVallejo, tomcat-users.xml is for granting access to the Tomcat Admin, etc. I'm talking about which user the java process is running as. ps -ef | grep java – HTTP500 Feb 23 '12 at 18:12
  • @HTTP500, not sure what info I'm looking at here but I am seeing one error: JVM-LIBDIR /usr/lib/jvm-exports/java-1.6.0-openjdk-1.6.0.0 does not exist or is not a directory -Dcatalina.base=/usr/share/tomcat6 – AlxVallejo Feb 23 '12 at 18:21
  • @AlxVallejo Well it's trying to create its index in the Tomcat home, not the Solr home. What did you configure in the context XML? – Shane Madden Feb 23 '12 at 18:57
  • @ShaneMadden, I used docBase="/data/solr/solr.war" – AlxVallejo Feb 23 '12 at 19:34
  • @AlxVallejo Still the same error? – Shane Madden Feb 23 '12 at 20:56
  • Yes, but shouldn't the solr instance be placed under /var/lib/tomcat6/webapps folder? You seemed to have placed it under /opt/solr/example/solr/ which is not in the scope of tomcat? – AlxVallejo Feb 23 '12 at 21:56
  • @AlxVallejo Typically Solr is installed outside the Tomcat webapps directory, so that a 'redeploy' doesn't blow up the configs and indexes. See the [install doc that I linked](http://wiki.apache.org/solr/SolrTomcat#Installing_Solr_instances_under_Tomcat); I believe your issue is due to needing to modify the `` setting in `solrconfig.xml` – Shane Madden Feb 23 '12 at 22:03
  • @ShaneMadden Thanks for the tips. I actually figured out that the reason for the 500 was due to permission settings. Tomcat creates a user not just for Tomcat but for CentOS as well, and that user was being denied write privilges on both the /data/solr/ and /usr/share/tomcat6 directories. For now I set them to 777 but at least I know that's what's causing the error. – AlxVallejo Feb 24 '12 at 18:31
  • @AlxVallejo Should be safe to just make the Tomcat user the owner of the directories, instead of making them writable to the world - glad it's working though! – Shane Madden Feb 24 '12 at 18:37