How to Download and Install Apache Solr on macOS

How to Download and Install Apache Solr on macOS

Apache Solr is a powerful open-source search platform built on Apache Lucene, used for handling large amounts of data and providing fast and efficient search capabilities. Here’s a step-by-step guide on how to download, install, and set up Apache Solr (version 9.7.0) on macOS.

Why Choose the Binary Release?

When downloading Apache Solr, you have several options, including source and binary releases. For most users, the binary release is the best choice since it comes pre-compiled with all the necessary files, allowing you to run Solr without needing to compile it from source. The latest version, as of now, is Solr 9.7.0, which includes important updates and bug fixes.

Step-by-Step Installation Guide

Step 1: Download Solr

To start, download the binary release for Solr 9.7.0 using the command below:

1. Open your terminal.

2. Run this command to download the Solr binary:

curl -O https://downloads.apache.org/lucene/solr/9.7.0/solr-9.7.0.tgz

Step 2: Extract the Files

Once the download is complete, you’ll need to extract the files from the compressed archive:

1. Use the following command to extract the .tgz file:

tar xzf solr-9.7.0.tgz

Step 3: Install Solr

After extraction, you can proceed with installing Solr:

1. Navigate to the extracted Solr directory:

cd solr-9.7.0

2. Start Solr in the background using the included script:

bin/solr start

Solr should now be running in the background, ready to process search requests.

Step 4: Access the Solr Dashboard

Once Solr is up and running, you can access its Admin UI to manage and monitor Solr:

1. Open your web browser.

2. Go to the following URL:

http://localhost:8983/solr

The Solr Admin UI will provide access to various tools and options for managing your search indexes.

Step 5: Stopping Solr

To stop Solr, you can use the following command:

bin/solr stop

Additional Notes

Using the Slim Version: If you prefer a more lightweight version, you can download solr-9.7.0-slim.tgz instead of the full release.

Java Requirements: Solr requires Java to run. You can verify if Java is installed by running:

java -version

If Java is not installed, you can install it using Homebrew:

brew install openjdk

Setting the JAVA_HOME Environment Variable: After installing Java, you may need to set the JAVA_HOME environment variable so Solr can locate your Java installation. Here’s how:

1. Run the following command to get the Java installation path:

/usr/libexec/java_home

2. Add the path to your environment configuration file. For macOS Catalina and later, which use Zsh as the default shell, open .zshrc:

nano ~/.zshrc

3. Add this line at the end of the file:

export JAVA_HOME=$(/usr/libexec/java_home)

4. Save the file and apply the changes:

source ~/.zshrc

For older macOS versions that use Bash, add the line to .bash_profile instead of .zshrc.

With these steps, you should have Apache Solr up and running on your macOS system. Enjoy exploring and building with this powerful search platform!

If you encounter any issues, refer to the Solr Reference Guide or seek community support for additional help.

Thanks for reading…

Happy Coding!