WEM – PowerShell Script to Edit Multiple Apache conf Files

A typical Web Experience Management (WEM, formerly CQ5) solution deployment involves the Apache HTTP Server as a load-balancer as well as a caching proxy for the “publish” instance(s). Configuration is typically spread across multiple configuration files, in addition to the main one (httpd.conf). These include dispatcher.any, the config file for the WEM Dispatcher.

If you needed to make small changes (like replacing the host name, or port), you have to do this in multiple files and in multiple locations within each file.

The PowerShell script that I used to automate this is available (URL is for Amazon S3, cached by Amazon CloudFront as a CDN).

The script captures input from the user on what to replace and what to replace it with, stops the Apache Windows service, backs up the original files, edits them, saves them, and starts the Apache Windows service.

Obviously, you will need to edit the script before running it in your environment. PowerShell is Windows’ preferred scripting environment. Both Windows 7 and Windows Server 2008 come with the Windows PowerShell ISE (Integrated Scripting Environment). You can use this IDE to edit the script.

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 0.0/10 (0 votes cast)
This entry was posted in Customer Experience Solutions, ADEP and tagged , , , , . Bookmark the permalink.

4 Responses to WEM – PowerShell Script to Edit Multiple Apache conf Files

  1. Great script.

    Is it your experience that many WEM/CQ customers are running Apache/Dispatcher on Windows? Also, do you have a Linux/Bash script that has the same functionality?

    • Christian:

      I pinged the Product Manager for WEM and he told me that for CQ instances themselves, Linux is the most popular OS. We don’t have data for the Dispatchers.

      No, I don’t have a bash script that’d do the same as this PowerShell script.

      • I thought about this for a moment and actually you don’t need a bash script to do this in Linux/Unix, all flavors have the SED command. This one-liner would do the same thing on Ubuntu as your script does for Windows. [Stop apache, create a backup of the original file, replace all strings with the given string in dispatcher.any, start apache].

        sudo /etc/init.d/apache2 stop && sed -i.bak “s/original-string/repalcement-string/g” /etc/apache2/conf/dispatcher.any && /etc/init.d/apache2 start


  2. Pingback: WEM – PowerShell Script to Edit Multiple Apache conf Files | Adobe LiveCycle Blog | The Winding Journal