Installing multi-core Apache Solr 4.x on Debian, Ubuntu, Red Hat, CentOS, and more
I've installed Apache Solr on a range of servers over the years. The consistent problems are I don't do it enough to memorize it, but it's enough to be frustratingly repetitive. I end up researching the process every time. I've discovered this is a common problem for many people. There are numerous blog posts describing the process in detail. Download this, configure that, etc. This time I needed to install Solr on two local dev machines, the staging server, and the production server. I thought: "Four times? Nope, I'm scripting this!"
The script installs the current multi-core Apache Solr 4.x.x in Tomcat 6 on the Debian, Ubuntu, LinuxMint, Red Hat, Fedora, and CentOS Linux operating system distributions. I've tested them with Solr 4.6 and 4.7. It will optionally install the Solr configurations supplied with the Drupal Apache Solr or Drupal Search API Solr modules. There are VagrantFile files for five distributions are included for testing.
It is available on GitHub: https://github.com/eosrei/install-apache-solr For your basic no-question automated install enter the following at the command line:
curl https://raw.github.com/eosrei/install-apache-solr/master/install.sh | sudo bash -s
If you don't trust running random scripts as root directly off GitHub or want to install one of the Drupal module configurations, then clone the repo first:
git clone https://github.com/eosrei/install-apache-solr.git cd install-apache-solr sudo ./install.sh
The install.sh supports the following command line options:
-a, --apachesolr-schema Install the current Drupal Apache Solr Search 7.x-1.x-dev module conf for Solr 4.x -h, --help Display help -s, --search-api-schema Install the current Drupal Search API Solr search 7.x-1.x-dev module conf for Solr 4.x
The script does the following:
- Checks command line options
- Checks for required programs
- Installs Tomcat 6
- Locates an Apache Mirror
- Downloads the most recent 4.x.x Solr
- Installs Solr
- Optionally installs the Drupal specific configurations
- Tests Solr for a valid response
After installation, you'll be able to access Solr at: http://localhost:8080/solr4/core0
Pull requests for additional Linux distributions, newer versions of Solr, or new features are greatly appreciated.
Warning: Be sure you need Solr before using it in your project. It is an attractive option, but often overkill. Are you indexing more than 100k items and/or expecting 100k users/day? Do you need Solr specific functionality? Be honest. Make sure your client is honest. Only 10k items? Your database can probably handle it. If you are using Drupal the Search API Database backend will often handle your needs. Even Drupal.org runs on the database-only backend (although it is an extreme example.)