---
url: 'https://metadrop.net/en/articles/installing-solr-4x-on-tomcat-7-on-debian-7'
title: 'Installing solr 4.x on tomcat 7 on debian 7'
author: 'Jorge Tutor'
date: '2017-01-17T10:08:15+00:00'
updated: '2026-06-10T06:37:56+00:00'
type: article
summary: 'how to install Solr on Tomcat on a Debian 7 distribution.'
tags:
  - Solr
  - Debian
  - Tomcat
published: true
og:
  determiner: Automatic
  site_name: Metadrop
  'image:alt': 'Installing solr 4.x on tomcat 7 on debian 7'
  street_address: 'Calle Manuel Luna, 12, 3 Dcha'
  locality: Madrid
  region: Madrid
  postal_code: '28020'
  country_name: España
  email: hola@metadrop.net
  phone_number: '910053180'
schema:
  '@context': 'https://schema.org'
  '@graph':
    -
      '@type': Article
      '@id': 'https://metadrop.net/en/articles/installing-solr-4x-on-tomcat-7-on-debian-7#article'
      name: 'Installing solr 4.x on tomcat 7 on debian 7'
      headline: 'Installing solr 4.x on tomcat 7 on debian 7'
      description: 'how to install Solr on Tomcat on a Debian 7 distribution.'
      about:
        - Solr
        - Debian
        - Tomcat
      datePublished: '2014-09-29T08:00:00+0200'
      dateModified: '2026-06-10T08:37:56+0200'
      author:
        '@type': Person
        name: 'Jorge Tutor'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
      mainEntityOfPage: 'https://metadrop.net/en/articles/installing-solr-4x-on-tomcat-7-on-debian-7'
    -
      '@type': Organization
      '@id': 'https://metadrop.net/#organization'
      url: 'https://metadrop.net/'
      name: Metadrop
      sameAs:
        - 'https://www.drupal.org/metadrop'
        - 'https://twitter.com/metadrop'
        - 'https://asociaciondrupal.es/partner/metadrop'
        - 'https://www.linkedin.com/company/metadrop'
      logo:
        '@type': ImageObject
        url: 'https://metadrop.net/themes/custom/mdrop_radix/logo-metadrop-500-500.jpg'
        width: '500'
        height: '500'
    -
      '@type': ItemPage
      '@id': 'https://metadrop.net/en/articles/installing-solr-4x-on-tomcat-7-on-debian-7'
      breadcrumb:
        '@type': BreadcrumbList
        itemListElement:
          -
            '@type': ListItem
            position: 1
            name: Home
            item: 'https://metadrop.net/en'
          -
            '@type': ListItem
            position: 2
            name: 'Expert Drupal & Tech Articles'
            item: 'https://metadrop.net/en/articles'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
---
 1. [Articles](https://metadrop.net/en/articles)
 
  

# Installing solr 4.x on tomcat 7 on debian 7

Monday, September 29, 2014

 

 



how to install Solr on Tomcat on a Debian 7 distribution.



   



Depending on your needs, you can install it through the package manager or manually. Installing via the package manager is always more convenient, as are updates, but depending on the repositories you use, it may be outdated, so the decision is up to you. Since this is a basic configuration to set up a quick solr service for testing, local, etc., the following guidelines are for the package manager:

## Java installation:

We install the basic java package.

```bash
# aptitude install openjdk-7-jre-headless
```

Optional:

```bash
# aptitude install java7-jdk
```

## Tomcat installation:

Base:

```bash
# apt-get install tomcat7
```

Administration panel:

```bash
# apt-get install tomcat7-admin
```

Check that it is running:

```bash
# service tomcat7 start
```

The default port for tomcat7 is 8080, we can check it by going to

```plaintext
http://localhost:8080
```

or

```plaintext
http://{IP}:8080/
```

Since port

```plaintext
8080
```

is often used by other services, we can change the port (e.g., 8983) with the following command.

```bash
# sed -i s/8080/8983/g /usr/local/tomcat/conf/server.xml
# service tomcat7 restart
```

## Authentication

For security reasons (in addition to any firewall we might set up) we will add a username and password to control access.

We edit the file:

```plaintext
tomcat-users.xml # vim /etc/tomcat7/tomcat-users.xml
```

We include the following instructions before the closing tag:

```xml
</tomcat-users>
```

```xml
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="your_username" password="your_password" roles="manager-gui,admin-gui"/>
```

We restart the machine:

```bash
# service tomcat7 restart
```

## Solr installation

We download the latest version of 4.x (http://www.apache.org/dyn/closer.cgi/lucene/solr)

```bash
 # wget http://archive.apache.org/dist/lucene/solr/4.10.0/solr-4.10.0.tgz | tar xz
```

We start from the default configuration of the Solr example and include it in tomcat's class path.

**Note:** The tomcat classpath directory contains symbolic links to the JARs in

```plaintext
/usr/share/java
```

You can do the same with the solr ones if you want, but since we will only use Solr from tomcat, we prefer to include them directly (in future updates you will only need to replace them).

```bash
 # cp ~/solr-4.10.0/example/lib/ext/* /usr/share/tomcat7/lib/
```

We include the Solr WARs inside Tomcat's webapps directory so that Tomcat can deploy the application.

**Note:** By default, tomcat deploys WARs in folders with the same name, so once deployed, the directory

```bash
/var/lib/tomcat7/webapps/solr
```

should exist. The service will run from there.

```bash
# cp ~/solr-4.10.0/dist/solr-4.10.0.war /var/lib/tomcat7/webapps/solr.war
```

## Catalina

Catalina is a Tomcat servlet container: the Tomcat server component that interacts with Java servlets.

We copy the solr example files to the Catalina directory:

```bash
/var/lib/tomcat7
```

and set the permissions so that Tomcat can interact.

```bash
# cp -R ~/solr-4.10.0/example/solr /var/lib/tomcat7
# chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr
```

The Solr application should appear listed as running at:

```plaintext
http://localhost:8080/manager/html
```

We restart the service to check that everything has been configured correctly.

```bash
# service tomcat7 restart
```

At this point Solr will be running at

```bash
http://localhost:8080/solr.
```

## Authentication

For security reasons, we add access protection to solr.

```bash
# service tomcat7 stop
```

Even if port 8080 is not publicly accessible, it is a good idea to set up authentication to prevent internal unauthorized access.

We edit the file

```plaintext
/var/lib/tomcat7/webapps/solr/WEB-INF/web.xml
```

(Includes the Solr app configuration).

```bash
# vim /var/lib/tomcat7/webapps/solr/WEB-INF/web.xml
```

We add the following instruction before the closing tag:

```xml
<security-constraint>
  <web-resource-collection>
    <web-resource-name>Solr GUI Authentication</web-resource-name>
    <url-pattern>/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>solr-gui</role-name>
  </auth-constraint>
 
  <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>
 
<login-config>
  <auth-method>BASIC</auth-method>
</login-config>
```

This adds a basic HTTP authentication (username and password) for the role

```bash
solr-gui
```

We edit the /etc/tomcat7/tomcat-users.xml file again to add a user with the created role:

```xml
<user username="your_username" password="your_password" roles="solr-gui"/>
```

We restart:

```bash
# service tomcat7 restart
```

We check that accessing

```plaintext
 http://localhost:8080/solr 
```

now asks for credentials. Similarly, we could have used the same user as before by adding the new role

```bash
solr-gui
```

```html
<user username="your_username" password="your_password" roles="manager-gui,admin-gui,solr-gui"/>
```

**Enjoy your new solr!**



[Solr](https://metadrop.net/en/articles?text=Solr)

[Debian](https://metadrop.net/en/articles?text=Debian)

[Tomcat](https://metadrop.net/en/articles?text=Tomcat)

 

- Jorge Tutor
    
    CIO
 
[Drupal Search Optimization with Solr / Elastic Search](https://metadrop.net/en/solutions/solr-elastic-search-drupal " See Drupal Search Optimization with Solr / Elastic Search")

Metadrop integrates Apache Solr and Elasticsearch with Drupal, delivering faceted search, multilingual indexing, and high-performance results for large-scale content platforms.

 

 See more