Last active
August 29, 2015 14:19
-
-
Save patrickocoffeyo/2efbbfe23712ea26ff61 to your computer and use it in GitHub Desktop.
Install Solr for Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function set_message() { | |
echo "### ### ### ###" >&2 | |
echo "### $1" >&2 | |
echo "### ### ### ###" >&2 | |
echo " " >&2 | |
} | |
# Installs and configures Tomcat. | |
function tomcat_install() { | |
set_message "Install and Configure Tomcat" | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre tomcat7 tomcat7-admin curl -y | |
sudo service tomcat7 stop | |
sudo rm /var/lib/tomcat7/conf/tomcat-users.xml | |
sudo touch /var/lib/tomcat7/conf/tomcat-users.xml | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><tomcat-users><role rolename=\"manager-gui\"/><role rolename=\"admin-gui\"/><user username=\"drupal\" password=\"InsertPasswordHere\" roles=\"manager-gui,admin-gui\"/></tomcat-users>" >> /var/lib/tomcat7/conf/tomcat-users.xml | |
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7 | |
sudo service tomcat7 start | |
} | |
function solr_dl() { | |
set_message "Download and unpack apachesolr in /tmp/solr." | |
mkdir /tmp/solr | |
cd /tmp/solr | |
curl -s http://archive.apache.org/dist/lucene/solr/4.9.1/solr-4.9.1.tgz -o solr-4.9.1.tgz | |
tar xf solr-4.9.1.tgz | |
set_message "Download and unpack Drupal apachesolr module." | |
curl -s http://ftp.drupal.org/files/projects/apachesolr-7.x-1.7.tar.gz -o apachesolr-7.x-1.7.tar.gz | |
tar xf apachesolr-7.x-1.7.tar.gz | |
} | |
function solr_install() { | |
set_message "Install solr." | |
sudo cp /tmp/solr/solr-4.9.1/example/lib/ext/* /usr/share/tomcat7/lib/ | |
sudo cp /tmp/solr/solr-4.9.1/dist/solr-4.9.1.war /var/lib/tomcat7/webapps/solr.war | |
sudo mkdir -p /var/lib/tomcat7/solr | |
sudo cp -r /tmp/solr/solr-4.9.1/example/solr/collection1/conf /var/lib/tomcat7/solr/ | |
sudo rsync -av /tmp/solr/apachesolr/solr-conf/solr-4.x/ /var/lib/tomcat7/solr/conf/ | |
sudo echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><solr persistent=\"false\"><cores adminPath=\"/admin/cores\"><core name=\"drupal\" instanceDir=\"drupal\" /></cores></solr>" >> /var/lib/tomcat7/solr/solr.xml | |
sudo mkdir -p /var/lib/tomcat7/solr/drupal/ | |
sudo cp -r /var/lib/tomcat7/solr/conf /var/lib/tomcat7/solr/drupal/ | |
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr | |
} | |
tomcat_install | |
solr_dl | |
solr_install | |
sudo service tomcat7 restart | |
sudo service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
sudo chmod +x thisscript.sh
)./thisscript.sh
)http://mylocalhost:8080/solr
, and ensure the apachesolr page appears.drupal
, password isInsertPasswordHere
. As indicated, you should change it.drupal
, so the solr URL from Drupal's perspective should behttp://localhost:8080/solr/drupal
.