Using Solr With TYPO3 On Debian Squeeze
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot]
com> Follow me on Twitter
Last edited 05/06/2013
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:
- server1.example.com (IP: 192.168.0.100): web server where the TYPO3 4.7 Introduction package is installed (in the www.example.com vhost).
- server2.example.com (IP: 192.168.0.101): 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
server2.example.com:
Open /etc/apt/sources.list…
vi /etc/apt/sources.list
… and make sure you have the contrib and non-free repositories enabled:
deb http://ftp.de.debian.org/debian/ squeeze 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:
wget http://forge.typo3.org/projects/extension-solr/repository/revisions/master/raw/resources/shell/install-solr.sh
chmod 755 install-solr.sh
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:
./install-solr.sh german english french
This installs a Tomcat server (where Solr is run on) and Solr. By default, Tomcat listens on 127.0.0.1 only; because we want to access Solr from a remote host, we must configure Tomcat to listen on all interfaces, therefore we replace 127.0.0.1 with 0.0.0.0 in /opt/solr-tomcat/tomcat/conf/server.xml:
vi /opt/solr-tomcat/tomcat/conf/server.xml
[...] |
Restart Tomcat:
/opt/solr-tomcat/tomcat/bin/shutdown.sh
/opt/solr-tomcat/tomcat/bin/startup.sh
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" ?> |
Restart Solr afterwards:
/opt/solr-tomcat/tomcat/bin/shutdown.sh
/opt/solr-tomcat/tomcat/bin/startup.sh
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:
[...] |
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:
[...] |
Restart Tomcat afterwards:
/opt/solr-tomcat/tomcat/bin/shutdown.sh
/opt/solr-tomcat/tomcat/bin/startup.sh
You can now open a browser and visit Solr under http://192.168.0.101:8080/solr 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:
Using Solr With TYPO3 On Debian Squeeze
Using Solr With TYPO3 On Debian Squeeze