Thursday, November 21, 2013

How to get gzip working for Jetty 8 and Solr

If you're getting the following error message in the solr.log file:

java.lang.ClassNotFoundException: org.eclipse.jetty.servlets.GzipFilter

Try doing the following:

Edit /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and put the following in it:


<web-app ... >


<filter>
      <filter-name>GzipFilter</filter-name>
      <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
      <init-param>
        <param-name>mimeTypes</param-name>  
        <param-value>text/html,text/plain,text/xml,application/xhtml+xml,application/xml,text/css,application/javascript,image/svg+xml,application/json,application/xml; charset=UTF-8</param-value>
      </init-param>
    </filter>
    <filter-mapping>
      <filter-name>GzipFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

If you don't have a jetty-servlets*.jar file, then download it from http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets and put it in /opt/solr/lib

Restart jetty:

sudo /sbin/service jetty restart

If solr doesn't start up, check the /opt/solr/logs/solr.log file.

Tuesday, November 19, 2013

How do I show PHP errors on a webpage?

In your /etc/php.ini file, add the following:

error_reporting(E_ALL);
ini_set('display_errors', 'on');

Friday, November 8, 2013

How to require password authentication for Apache Solr 4 and Jetty

Some of the documentation in the Solr wiki is outdated, so here's what worked for me.  In the following files, you can change the highlighted fields.

Edit /opt/solr/etc/jetty.xml and add the following:

<Configure>

    <Call name="addBean">
      <Arg>
        <New class="org.eclipse.jetty.security.HashLoginService">
          <Set name="name">Test Realm</Set>
          <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
          <Set name="refreshInterval">0</Set>
        </New>
      </Arg>
    </Call>

...

</Configure>

Edit  /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and add the following:

<web-app>
...
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Solr authenticated application</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>core1-role</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Test Realm</realm-name>

  </login-config>

...
</web-app>

Create a file in /opt/solr/etc/realm.properties and put the following in it:

admin: yourPasswordHere,core1-role

You can change "admin" to whatever username you want.

For the password, you can either use the literal password, or use an OBF/MD5/CRYPT hash.  To create a hash, you can do the following:

cd /opt/solr
java -cp /lib/jetty-util-8.1.10.v20130312.jar org.eclipse.jetty.util.security.Password admin yourPasswordHere

The above utility will print out the hash to the screen, and you can chose either the OBF, MD5, or CRYPT line.  Make sure that you copy the entire line, including the "OBF:..." part.  Copy this line to the /opt/solr/etc/realm.properties file; the result will look something like this:

admin: OBF:1x1v1xmk1w9b1pyh1oq31uum1xtv1zej1zer1xtn1uvk1or71pw51w8f1xmq1x0r
,core1-role

The above is all in one line.  No line break.  Make sure you put the comma before the "core1-role".

After you've changed everything, restart the solr server.  If you're using Fedora, do this:

sudo /sbin/service jetty.sh restart

Then open up your web browser to http://localhost:8983/solr/#/collection1/query and the web browser should ask you for a password.  Enter admin for the user name and yourPasswordHere for the password.

Hint: if you get an error on the Solr admin webpage, you can check the log for warning messages.  The log file is here: /opt/solr/logs/solr.log

More info:



Monday, November 4, 2013

Ruby, yaml, and gem in Fedora Linux

If you're trying to use gem to install something, and you're getting the following error message:

It seems your ruby installation is missing psych (for YAML output)....

You could try to install libyaml like this:

yum install libyaml

If that still doesn't work, it might be because the libyaml library is not new enough.  If that's the case, install libyaml from source from here:

http://pyyaml.org/download/libyaml/

Then, uninstall ruby, and then re-install ruby.  Hopefully you'll have success after that.