Setting up a SolR server for TYPO3
Prerequisites
This tutorial assumes you have a root server set up. A small VPS server is sufficient. I've used a CX11 VPS from Hetzner for under 3 EUR (https://www.hetzner.com/cloud).
Update the package manager and install required packages
apt update;apt upgrade -y
Install required apt packages
sudo apt install openjdk-8-jdk git curl -y
We need openjdk for the solr server, git to get the solr configuration files from the TYPO3 solr extension and curl to use the REST API to change the password for the solr admin.
Get TYPO3 solr extension files
We need the SolR configuration files that come with the TYPO3 solr extensions. We clone the repository for EXT:solr from GitHub
git clone github.com/TYPO3-Solr/ext-solr.git
Find out the release of the extension that you will install for your TYPO3 (in my case 10.0.3) and check it out
cd ext-solr/
git checkout 10.0.3
Installing SolR core
tar xzf solr-8.8.2.tgz solr-8.8.2/bin/install_solr_service.sh --strip-components=2
sudo bash ./install_solr_service.sh solr-8.8.2.tgz
Configure Solr to work with TYPO3 and EXT:solr
In these steps you will copy the special Solr configuration that comes with the EXT:solr extension to the filesystem locations where Solr is installed. Solr needs these configuration files so that it will know how to index TYPO3 content.
cp -r ~/ext-solr/Resources/Private/Solr/configsets /var/solr/data
cp ~/ext-solr/Resources/Private/Solr/solr.xml /opt/solr/server/solr/solr.xml
Now you will use Solr's REST api to create the three Solr cores that will be used to index the web site content for the three default languages (English, German, Danish) of the TYPO3 Official Introduction Package
Note: At the time this tutorial was written the version of EXT:solr used was 10.0.3. Make sure to check what version of EXT:solr you have and replace the version number in the commands below. And make sure you replace the decimals in the version number with underscores (for instance 10.0.3 becomes 10_0_0) for the curl commands below.
curl "http://localhost:8983/solr/admin/cores?action=CREATE&name=xxxx_de&configSet=ext_solr_10_0_0&schema=german/schema.xml&dataDir=german"
Secure SolR by requiring authentication
Create a basic authentication file at /var/solr/data/security.json
{
"authentication":{
"blockUnknown": true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}
},
"authorization":{
"class":"solr.RuleBasedAuthorizationPlugin",
"permissions":[{"name":"security-edit",
"role":"admin"}],
"user-role":{"solr":"admin"}
}}
Make it writable by the solr engine
chmod 666 /var/solr/data/security.json
Restart the solr service
service solr restart
Reconfigure the password:
curl --user solr:SolrRocks localhost/solr/admin/authentication -H 'Content-type:application/json' -d '{"set-user": {"solr" : "PASSWORD"}}'
Additional information regarding authentication can be found here https://lucidworks.com/post/securing-solr-basic-auth-permission-rules/