Quick Start Guide for Apache Solr Installation

Apache Solr is a high-performance, scalable full-text search server developed by Apache, widely used in log analysis, e-commerce search, and content management systems. For developers, quickly setting up a local or production environment Solr instance serves as the starting point to master its core capabilities. This guide provides detailed instructions on how to perform rapid installation and basic configuration using official binary packages across mainstream Linux distributions.
Before beginning the installation process, ensure your server meets the following basic environmental requirements. Apache Solr has specific version constraints for operating systems; it is recommended to prioritize Ubuntu 18.04 LTS, CentOS 7, or Debian 9 (or later versions). Additionally, since Solr runs on Java, you must confirm that a compliant JDK (Java Development Kit) is installed in the system. The recommended versions are JDK 11 or JDK 17.

You can check your current Java environment using the java -version command. If it is not installed or the version is too low, configure it first via package managers or the official download page. Furthermore, ensure that your system time is accurate; Solr heavily relies on synchronized timing mechanisms for log recording and distributed coordination.

Downloading Official Binary Packages

Apache provides pre-compiled binary packages tailored for mainstream Linux distributions, which represents the most convenient deployment method. Visit the Apache Solr release page (https://solr.apache.org/download/) to select the corresponding .tar.gz archive file based on your operating system. For example, on an Ubuntu 20.04 system, you typically download a file named solr-9.x.x-linux-x86_64.tgz.

After downloading, save the file to a local temporary directory using wget or a browser to avoid potential permission issues caused by direct downloads into the system root directory. It is recommended to extract the files using the command tar -xzf solr-9.x.x-linux-x86_64.tgz, and then move the extracted folder to a fixed path such as /opt/solr for easier management in subsequent steps.

Configuring Environment Variables and Starting Services

After extracting and moving the Solr directory, the next step is to configure environment variables to simplify the startup process. Open the ~/.bashrc or ~/.profile file and add the following configuration items:

export SOLR_HOME=/opt/solr
export PATH=$SOLR_HOME/bin:$PATH

After saving the file, execute source ~/.bashrc to make the configuration take effect immediately. At this point, entering solr --version in the terminal should correctly display Solr version information, proving that the environment variable setup was successful.

There are two ways to start the Solr service: direct command-line startup or background daemon mode. It is recommended to use the nohup solr start command for non-blocking startup; this redirects output to a log file and avoids blocking terminal operations. If you need to configure automatic startup on boot, execute solr config init to initialize configuration files, followed by using systemd or service commands to manage the service lifecycle.

Verifying Installation and Basic Testing

After installation is complete, it is essential to verify whether Solr is running correctly via its web interface. By default, Solr listens on port 8983; you can access the dashboard by visiting http://localhost:8983/solr/ in your browser. If the page displays the Solr welcome message and core information, it indicates that the basic service is ready.

To further test search functionality, simple query operations can be executed using command-line tools. For example, create a collection named test_core and add documents:

curl -X POST "http://localhost:8983/solr/admin/collections?action=CREATE&name=test_core" \
     -H "Content-Type: application/json" \
     -d '{"schema": {"fields": [{"name":"title","type":"string"}]}}'

Subsequently, send a query request via curl:

curl "http://localhost:8983/solr/test_core/select?q=title+is+like+%27%25hello%25%27"

If the response includes JSON data containing matching results, it indicates that both Solr's indexing and search functionalities are working correctly. This verification step helps quickly identify potential configuration errors to ensure smooth subsequent development work.