Log inSign up

A private Apache Solr search server on Ubuntu or Debian

Install a Java runtime, download the current Solr release, extract install_solr_service.sh and run it; Solr then runs as the solr user under /opt/solr with data in /var/solr, listening on 127.0.0.1 port 8983. Create a core with bin/solr create, send documents to its update handler and query /select. Reach the admin UI through an SSH tunnel or an Nginx proxy with a password and TLS.

Topic: Databases · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13 · Updated 2026-12-03

What does Solr need on a VPS?

Solr needs a Java runtime, memory for its heap plus the operating system file cache, and an Ubuntu or Debian server with a sudo user. Solr 9 runs on Java 11 or newer; Java 21 is a good match and is required if the download page already offers a newer major release.

Memory is the main sizing question. Give the Java heap 1 to 2 GB for a small index and leave at least as much again free, because Solr reads index files through the page cache. A 4 GB server is a sensible start for a catalogue of a few hundred thousand documents. Install Java:

sudo apt update
sudo apt install -y openjdk-21-jre-headless curl lsof    # Ubuntu 24.04, 22.04, Debian 13
sudo apt install -y openjdk-17-jre-headless curl lsof    # Debian 12
java -version

The lsof package is used by the Solr start script to check its port.

How do you install Solr as a service?

Download the binary release, pull the installer script out of the archive and run it as root against the same archive. Set the version to the one listed as current on the Solr download page and verify the checksum.

SOLR_VER=9.9.0          # replace with the current release
cd /tmp
curl -fLO https://dlcdn.apache.org/solr/solr/$SOLR_VER/solr-$SOLR_VER.tgz
curl -fLO https://dlcdn.apache.org/solr/solr/$SOLR_VER/solr-$SOLR_VER.tgz.sha512
sha512sum -c solr-$SOLR_VER.tgz.sha512
tar xzf solr-$SOLR_VER.tgz solr-$SOLR_VER/bin/install_solr_service.sh --strip-components=2
sudo bash ./install_solr_service.sh solr-$SOLR_VER.tgz

The script creates the solr system user, unpacks to /opt/solr-$SOLR_VER with a /opt/solr symlink, puts data and logs in /var/solr, writes settings to /etc/default/solr.in.sh and registers a solr service that starts at boot. Older releases move off the main mirror to the Apache archive, so if the download returns 404, check the current version number first.

How do you check that Solr is running?

Ask the service manager, confirm the listening address and query the system info API from the server itself.

sudo systemctl status solr --no-pager
sudo ss -ltnp | grep 8983
curl -s "http://127.0.0.1:8983/solr/admin/info/system?wt=json" | head -n 20
sudo -u solr /opt/solr/bin/solr status

Since Solr 9 the default SOLR_JETTY_HOST is 127.0.0.1, so the port is not reachable from outside even without a firewall rule. Keep it that way. If ss shows 0.0.0.0:8983, set SOLR_JETTY_HOST="127.0.0.1" in /etc/default/solr.in.sh and restart. Port 8983 should also stay closed in UFW.

How do you size the heap and other settings?

Edit /etc/default/solr.in.sh: set the heap with SOLR_HEAP, keep the host binding local, and restart the service.

sudo nano /etc/default/solr.in.sh
# set or uncomment:
SOLR_HEAP="1g"
SOLR_JETTY_HOST="127.0.0.1"
SOLR_TIMEZONE="UTC"

sudo systemctl restart solr

Do not give the heap most of the RAM: a heap that is too large starves the page cache and slows searches. Raise it only when logs show memory pressure. The installer also raises the open file and process limits Solr asks for; if bin/solr status warns about ulimits, set LimitNOFILE=65000 in a systemd override with sudo systemctl edit solr. Watch memory over time with the tools in usage monitoring.

How do you create a core and define fields?

Create a core as the solr user, then add the fields you need through the Schema API instead of relying on guessed field types.

sudo -u solr /opt/solr/bin/solr create -c catalog

curl -s -X POST -H 'Content-Type: application/json' http://127.0.0.1:8983/solr/catalog/schema --data-binary '{
  "add-field": [
    {"name": "title",    "type": "text_en",  "stored": true},
    {"name": "body",     "type": "text_en",  "stored": true},
    {"name": "category", "type": "string",   "stored": true, "docValues": true},
    {"name": "price",    "type": "pfloat",   "stored": true}
  ]
}'

The _default config set adds unknown fields automatically on first sight, which is fine for experiments but leads to wrong types in production. Turn it off once your fields are defined:

curl -s http://127.0.0.1:8983/solr/catalog/config -d '{"set-user-property": {"update.autoCreateFields": "false"}}'

text_en applies English tokenising and stemming, string keeps the value exact for filters and facets, and pfloat is a numeric field for sorting and ranges.

How do you index and search documents?

Send JSON documents to the core's /update handler with commit=true, then query the /select handler with parameters for the query, filters, facets and highlighting.

curl -s -X POST -H 'Content-Type: application/json' 'http://127.0.0.1:8983/solr/catalog/update?commit=true' --data-binary '[
  {"id": "p1", "title": "NVMe VPS with four cores", "body": "Fast disks for databases and build jobs", "category": "vps", "price": 24.0},
  {"id": "p2", "title": "Backup storage guide", "body": "Encrypted nightly backups with restic", "category": "docs", "price": 0}
]'

curl -s 'http://127.0.0.1:8983/solr/catalog/select?q=title:vps%20OR%20body:databases&fl=id,title,score'
curl -s 'http://127.0.0.1:8983/solr/catalog/select?q=*:*&fq=category:vps&facet=true&facet.field=category&rows=0'
curl -s 'http://127.0.0.1:8983/solr/catalog/select?q=body:backup&hl=true&hl.fl=body'

q is the scored query, fq filters without affecting score and is cached separately, fl picks returned fields, and facets count values per field. Your application usually pushes changes from its database to Solr in small batches; in production use commitWithin=5000 instead of committing every request.

How do you reach the admin UI safely?

For your own use, tunnel the port over SSH; for a team or an application on another server, put Nginx in front with HTTPS and a password, and never expose 8983 directly.

# from your own computer, then open http://127.0.0.1:8983/solr/
ssh -N -L 8983:127.0.0.1:8983 deploy@198.51.100.24

For the proxy route, create a password file and a server block:

sudo apt install -y nginx apache2-utils
sudo htpasswd -c /etc/nginx/solr.htpasswd deploy
server {
    listen 443 ssl;
    server_name search.example.net;
    ssl_certificate     /etc/letsencrypt/live/search.example.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/search.example.net/privkey.pem;

    location /solr/ {
        auth_basic "Solr";
        auth_basic_user_file /etc/nginx/solr.htpasswd;
        proxy_pass http://127.0.0.1:8983;
        proxy_set_header Host $host;
    }
}

Get the certificate with Certbot, then test with sudo nginx -t and reload. Solr also has its own BasicAuth and rule-based authorization plugins configured in security.json; run /opt/solr/bin/solr auth --help for the options in your version if you prefer authentication inside Solr itself.

How do you upgrade, back up and troubleshoot Solr?

Upgrade by running the installer for the new version with -f, which repoints /opt/solr and keeps /var/solr; back up cores with the replication backup command or by copying the data directory while Solr is stopped; and read /var/solr/logs/solr.log for errors.

sudo bash ./install_solr_service.sh solr-NEW.tgz -f
curl -s 'http://127.0.0.1:8983/solr/catalog/replication?command=backup&location=/var/solr/backups&name=nightly'
sudo tail -n 50 /var/solr/logs/solr.log
sudo journalctl -u solr -n 30 --no-pager

Create /var/solr/backups owned by solr first, and make sure the path is allowed by SOLR_OPTS="$SOLR_OPTS -Dsolr.allowPaths=/var/solr/backups" in solr.in.sh. Read the release notes before a major upgrade, since indexes built by much older versions may need a reindex from your source data. Common failures are an out-of-memory heap, a missing Java runtime after an OS upgrade and a full disk under /var/solr. If your data already lives in PostgreSQL, compare with built-in full-text search before adding another service.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4heap plus file cache for a small index2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A4-8larger catalogues and faceting4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months

Questions about Apache Solr search server

Is Solr a database?

It is a search server built on Apache Lucene. It stores documents and can be the source of truth, but most setups keep data in a relational database and copy what needs searching into Solr.

Should I run Solr in standalone or SolrCloud mode?

Standalone is simpler and enough on one server. SolrCloud with ZooKeeper adds sharding and replication across several machines when one server is no longer enough.

Why can I not open the admin UI from my browser?

Solr listens only on 127.0.0.1 by default. Use an SSH tunnel such as ssh -N -L 8983:127.0.0.1:8983 deploy@198.51.100.24, or the Nginx proxy shown above.

How much memory should the Solr heap get?

Start with 1 GB and leave at least as much RAM free for the file cache. Raise the heap only when logs show garbage collection pressure or out-of-memory errors.

Does this work on Rocky Linux or AlmaLinux?

The installer script also supports Red Hat style systems with a Java package from dnf, but this guide covers and was written for Ubuntu and Debian only.