Categories
Unix & Linux

How to install and run Apache Solr 9.x on FreeBSD

Before you begin this guide, you should have a FreeBSD 13.2 server.

Solr needs the Java version 11 or higher. Java 11 has been extensively tested by both automated tests and users through Solr 9. Long Term Support (LTS) for Java 11 is provided from several sources. Java 12, 13, 14, 15 and 16 have no LTS. For this reason, Java 17 is preferred when upgrading Java. But we will use OpenJDK as free and lightweight alternative.

You can install it with commands:

# cd /usr/ports/java/openjdk17
# make install clean

This OpenJDK implementation requires a few file systems to be mounted for full functionality. Run these commands to perform the required mounts immediately:

    mount -t fdescfs fdesc /dev/fd
    mount -t procfs proc /proc

To make it permanent, you need the following lines in /etc/fstab:

    fdesc    /dev/fd        fdescfs        rw    0    0
    proc    /proc        procfs        rw    0    0

Now you can check your Java version like this:

# java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-1, mixed mode, sharing)

Now you can install Apache Solr with commands:

# cd /usr/ports/textproc/apache-solr
# make install clean

Make sure to edit the following files to adapt to your setup:

/usr/local/etc/solr.in.sh
/var/db/solr/solr.xml

All files are configured to have your solr instances running in:

/var/db/solr/<instancename>

For more information how to configure solr check the manual.

The port is configured to listen only on localhost, port 8983.

To rotate logs include /var/log/solr/ to your log rotation
configuration.

To enable the port execute:

sysrc solr_enable="YES"
# service solr start

And start it with:

Leave a Reply

Your email address will not be published. Required fields are marked *