Solr, WordPress & OSX Server

I have long been a fan of WordPress and not so much a fan of the search engine functionality that comes boxed with it. As an Apple Systems Admin I have several WordPress websites running on several OSX Servers. One of the sites that I administer finally got to the size to where the search capabilities of WordPress fell short of the clients desire and I was forced to look into other avenues for searching. I came across, solar. Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON APIs, hit highlighting, faceted search, caching, replication, and a web administration interface. This looked extremely promising however getting all of the information that I needed in order to get this running on my servers proved to be a cumbersome process, so I am now writing this to consolidate all of the steps and information that I learned while installing and getting Solr to run on our servers.

The first step is to download all of the needed files, download the most recent version of Solr, and the Solr for WordPress plugin. The first part of the documentation here will be on how to install and get Solr running and then the second portion will focus on configuring the Solr for WordPress plugin. For this walkthrough I will be using the example application that comes with Solr. ** Before we proceed you need to open the port 8983 in your servers firewall and or hardware firewall appliance for public access.

  1. Expand the Solr archive into a folder in the Applications folder called Solr (/Applications/Solr)

  2. For testing and development we can use the example application coming with Solr. This application is found at /Applications/Solr/example.

  3. Move the schema.xml that comes with the Solr for WordPress in the folder* /Applications/Solr/example/solr/conf/* (add “.backup” to the original file).

Now start the solr application by opening the Terminal and executing the command:

cd /Applications/Solr/example/

java -jar start.jar

Test that your solr server is now available by visiting https://localhost:8983/solr/admin/

now that you have Solr running on your osx server, you need to make sure that it will run in the background even when you logout of the computer. At the moment it is running through Java and when you logout it will stop running. In order to accomplish this you need to create a LaunchD item, this item needs to be placed in the /Library/LaunchDaemons/ folder.

  1. Create a new text file name it org.apache.solr.plist

  2. Enter the following information into the file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN https://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
   <dict>
      <key>Label</key>
      <string>org.apache.solr</string>
      <key>WorkingDirectory</key>
      <string>/Applications/Solr/example</string>
      <key>ProgramArguments</key>
      <array>
         <string>/usr/bin/java</string>
         <string>-Dezfind</string>
         <string>-jar</string>
         <string>/Applications/Solr/example/start.jar</string>
      </array>
      <key>RunAtLoad</key>
      <true />
   </dict>
</plist>

Once done, place this file in the /Library/LaunchDaemons/ folder and then run this command in terminal

sudo launchctl load /Library/LaunchDaemons/org.apache.solr.plist

this will load the Launch Daemon when the computer restarts, the next step is to restart your server and then make sure that Solr is running by going to the Solr admin URL https://localhost:8983/solr/admin/ or https://server.domain.name:8983/solr/admin/

Now that you have Solr running on the server, and the schema file loaded then you need to make sure that the Solr for WordPress plugin is installed. Note: Solr, does not need to run on the same server as your wordpress install, we have a dedicated Mac Mini server running Solr and it works great. To install Solr for WordPress follow these steps.

  1. Upload the solr-for-wordpress folder to the /wp-content/plugins/ directory

  2. Activate the plugin through the ‘Plugins’ menu in WordPress

  3. Configure the plugin with the hostname, port, and URI path to your Solr installation.

  4. Load all your posts and/or pages via the “Load All Posts” button in the settings page

Note that this plugin requires you to have an instance of Solr using a schema with the following fields: id, permalink, title, content, numcomments, categories, categoriessrch, tags, tagssrch, author, type, and text. The facet fields (categories, tags, author, and type) should be string fields. You can make tagssrch and categoriessrch of any type you want as they are used for general searching. The plugin is distributed with a Solr schema you can use at solr-for-wordpress/schema.xml.

Now that the plugin is installed and active, login to the administrative area of your WordPress website and go to the “Settings –> Solr Options” area. Once here enter the IP address or Fully Qualified Domain that is running solar. Enter the Port, which in this document is 8983 and enter /solr for the path. Once done, press “Save Changes” it will test the connection to the server and will let you know if it can connect or not.

Once you have gotten the plugin to connect you can “Load All Pages” and “Load All Posts” to build your initial Solr database. Your almost complete now you need to integrate the search results that you get from the Solr server into your WordPress website.

Custom Theme Integration

  1. Create a new theme file called “s4w_search.php”.

  2. Insert your markup, use template methods s4w_search_form() and s4w_search_results() to insert the search box and results respectively.

  3. Add result styling to your theme css file, see solr-for-wordpress/template/search.css for an example.

  4. You can use the search widget in your sidebar for search, or use a custom search box that submits the query in the parameter “s”.

For more information about integrating Solr into your WordPress website you can go to https://wordpress.org/extend/plugins/solr-for-wordpress/

I certainly welcome your feedback so if you have an questions or comments feel free to post them below.

AI Usage Transparency Report

Pre-AI Era · Written before widespread use of generative AI tools

AI Signal Composition

Tone Struct List Instr
Repetition: 0%
Tone: 33%
Structure: 52%
List: 13%
Instructional: 50%
Emoji: 0%

Score: 0.05 · Low AI Influence

Summary

A step-by-step guide to installing and configuring Solr on an OSX server for use with WordPress.

Related Posts

Low Profile Walkthrough and Review

Today I’m walking through Low Profile, a utility from Nindi Gill that I use when I want to inspect profiles already installed on a Mac and figure out whether those profiles contain issues I need to clean up. The value is that Low Profile gives me a straightforward way to inspect profiles installed on any Mac. This simplicity makes it easy for me to identify and address potential problems, which is especially useful when working with multiple machines or troubleshooting complex profile configurations.

Read more

ABM Warranty 0.4.1 Walkthrough: Multiple Credentials

In this part of the ABM Warranty 0.4.1 walkthrough series, I’m focusing on multiple credentials. In the first video, I showed the basic setup and how to add a single credential. Now, I want to explore what happens when I remove a credential, what changes occur when I add more than one, and how the app behaves once there are multiple contexts in play. This will help clarify any potential issues or inconsistencies that may arise with multiple credentials.

Read more

QuickPKG Walkthrough and Review

I use QuickPKG when I need to turn an application, DMG, or ZIP file into a package quickly without wasting time in a heavier packaging workflow. This post follows the same path as my video: what QuickPKG is, where to get it, how I run it, what a simple packaging example looks like, and where I think admins need to be careful about potential pitfalls that can arise from using this tool.

Read more

Amphetamine: The Ultimate Mac Utility to Keep Your Computer Awake

In today's fast-paced digital world, keeping your computer awake during important tasks is crucial. Enter **Amphetamine**, a powerful utility designed specifically for Mac users. This app ensures that your system remains active, preventing it from going to sleep or activating the screensaver when you need it most. In this article, we will explore the features of Amphetamine, how to use it effectively, and why it’s a must-have for Mac admins and everyday users alike.

Read more

Mactracker Walkthrough and Review

In the world of Mac administration, having the right tools at your disposal is crucial. One of the standout applications that every Mac admin should consider is **Mac Tracker**. This powerful app serves as a comprehensive database of all historical Mac OS versions and Apple accessories, making it an invaluable resource for both seasoned professionals and newcomers alike. In this article, we will explore the features of Mac Tracker, how it can enhance your workflow, and why it deserves a spot in your toolkit.

Read more

XCodes Walkthrough and Review

Xcodes is an amazing native application that you can use to switch back and forth between different versions of XCode on your Mac. Why would you need this? Some developers need to test beta versions of XCode and manually switching back and forth is a huge pain. You can only have one active version of XCode if your using the CLI and its hard to remember which one you left activated and which versions are actually installed.

Read more

Hancock Walkthrough and Review

Back in 2016, Hancock was created at the MacAdmins PSU conference during the Hackathon, where it took home the award for "Biggest Time Saver". We'd like to extend our thanks to Jeremy Agostino for developing a great little utility that has since become an essential tool for many.

Read more