If you’re running Magento Enterprise Edition (and in my opinion anyone serious about eCommerce on Magento should be), one of the power features you get that isn’t available out of the box on the Community Edition is Solr support. As most of our clients choose to take advantage of this, I have spent a fair amount of time learning and setting up Solr on multiple systems. Depending on how you choose to run your system you may want to control starting and stopping Solr manually or (for the sake of this post) would rather have it run as an automatically restarting script.
Below is a quick script for setting this up, it has been tested in Ubuntu 12.04, but should work elsewhere without issues
Step 1) install and setup Solr as usual
Step 2) copy you Solr instance to /usr/local/solr/MYSOLRINSTANCE (where MYSOLRINSTANCE is the name you have chosen for this instance of Solr)
Step 3) create the file /etc/init.d/solr and copy the following into it (be sure to change MYSOLRINSTANCE in the script below to match the directory name used in step 2)