Using Solr With TYPO3 On Debian Squeeze

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter

TYPO3's default search extension called "Indexed Search" is fine for small web sites, but if your web site is bigger (> 500 pages), it is getting very slow. Fortunately, you can replace it with a search extension that uses the ultra-fast Apache Solr search server. This tutorial explains how to use Apache Solr with TYPO3 on Debian Squeeze.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

In this tutorial I'm using two servers:

  • (IP: web server where the TYPO3 4.7 Introduction package is installed (in the vhost).
  • (IP: separate server where I will install Apache Solr.

Of course, it's possible to install Solr on the same system as the web server; however, I'd like to split up both services so that they do not impact each other's performance.


2 Installing Solr

Open /etc/apt/sources.list...

vi /etc/apt/sources.list

... and make sure you have the contrib and non-free repositories enabled:

deb squeeze main contrib non-free
deb-src squeeze main contrib non-free

deb squeeze/updates main contrib non-free
deb-src squeeze/updates main contrib non-free

deb squeeze-updates main contrib non-free
deb-src squeeze-updates main contrib non-free

Update your packages database...

apt-get update

... and install Java:

apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre unzip

update-alternatives --config java
update-alternatives --config javac

The TYPO3 project provides a Solr installation script which we download as follows:

chmod 755

Now we install Solr. By default (if you don't provide any languages as parameters), Solr is installed with support for the English language only; if you need support for more languages, just append them to the command, e.g. like this:

./ german english french

This installs a Tomcat server (where Solr is run on) and Solr. By default, Tomcat listens on only; because we want to access Solr from a remote host, we must configure Tomcat to listen on all interfaces, therefore we replace with in /opt/solr-tomcat/tomcat/conf/server.xml:

vi /opt/solr-tomcat/tomcat/conf/server.xml

    <Connector port="8080" protocol="HTTP/1.1"
               URIEncoding="UTF-8" />

Restart Tomcat:


Next we can configure cores in Solr. By default, an English core is already configured; if you need more languages, you can add them to /opt/solr-tomcat/solr/solr.xml, e.g. like this:

vi /opt/solr-tomcat/solr/solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
        <cores adminPath="/admin/cores" shareSchema="true">
                <core name="core_en" instanceDir="typo3cores" schema="english/schema.xml" dataDir="data/core_en" />
                <core name="core_de" instanceDir="typo3cores" schema="german/schema.xml" dataDir="data/core_de" />
                <core name="core_fr" instanceDir="typo3cores" schema="french/schema.xml" dataDir="data/core_fr" />

Restart Solr afterwards:


Because we don't want to start Tomcat manually each time the server is booted, we can add the Tomcat startup command to /etc/rc.local:

vi /etc/rc.local



2.1 Adding Authentication To Solr

Because Solr is listening on all interfaces, it is a good idea to add authentication to it. I will now configure the user user1 with the password secret for the English core.

Open /opt/solr-tomcat/tomcat/conf/web.xml...

vi /opt/solr-tomcat/tomcat/conf/web.xml

... and add the following section somewhere inside the <web-app> container:

      <web-resource-name>Solr authenticated application</web-resource-name>

    <realm-name>Admin and Update protection</realm-name>

As you see, this is valid for the English core only (<url-pattern>/core_en/*</url-pattern>), and I've configured this for the role role1, so valid users must belong to that role. To add the user user1 with his password to that role, open /opt/solr-tomcat/tomcat/conf/tomcat-users.xml...

vi /opt/solr-tomcat/tomcat/conf/tomcat-users.xml

... and add the following section inside the <tomcat-users> container:

  <role rolename="role1"/>
  <user username="user1" password="secret" roles="role1"/>

Restart Tomcat afterwards:


You can now open a browser and visit Solr under where you should see all configured cores:

When you visit the English core (for which we have just configured authentication), you should be asked for a username and a password:

After successful authentication, you should see the following page which means Solr is running successfully:

Falko Timme

About Falko Timme

Falko Timme is an experienced Linux administrator and founder of Timme Hosting, a leading nginx business hosting company in Germany. He is one of the most active authors on HowtoForge since 2005 and one of the core developers of ISPConfig since 2000. He has also contributed to the O'Reilly book "Linux System Administration".

Share this page:

Suggested articles

0 Comment(s)

Add comment