NOTE: Just noticed that SyntaxHighighter isn't rendering my Apache code correctly (the directory element gets altered). The code is right but it doesn't display properly.

I had previously blogged about how to integrate Jaxer into a standard installation of Apache. When I completed my Apache + Jaxer setup, I had it configured in such a way that I had to run Jaxer at all times. This was because, in order for Jaxer to do its thing, all HTML files (often includes PHP files) run through the Jaxer server. Of course, such an approach makes sense. Jaxer executes script blocks tagged with the attribute run-at (run-at='server' or run-at='both').

When I setup Jaxer to work with my default instance of Apache, I added the following code to my Apache httpd.conf file:

<directory "/Users/myusername/Sites">
...other code removed for brevity...
JaxerFilter .html .xhtml .htm .php
JaxerFilterContentType text/html application/xhtml+xml

The 'problem' was that I just told Apache that for any file (of types .htm, .html, .xhtml, .php) in this directory or subdirectory to be filtered by Apache. Naturally, Apache would thrown an error if such a file was requested and the Jaxer server was not running.

It wasn't a big deal, as I set Jaxer to run at start up with the system.

As I am still increasing my knowledge of Apache (I started out using IIS and never really touched Apache until last year), I had an epiphany the other day as I was working on integrating Tomcat with my Apache. I realized that I could add a Directory tag/element to my Virtual Host elements for Jaxer-based sites...duh!!!

So, I removed the two lines from the Directory element above and added the following to all Virtual Host elements in my httpd-vhosts.conf file that use or require Jaxer.

<virtualhost *:80>
ServerAdmin sompin@gmail.com
DirectoryIndex index.html index.htm index.php
DocumentRoot /Users/myusername/Sites/jaxersite1
ServerName dev.baddogsconsulting.com
<directory "/Users/myusername/Sites/jaxersite1">
JaxerFilter .html .xhtml .htm .php
JaxerFilterContentType text/html application/xhtml+xml



<virtualhost *:80>
ServerAdmin sompin@gmail.com
DirectoryIndex index.html index.htm index.php
DocumentRoot /Users/myusername/Sites/jaxersite2
ServerName dev.jax-blog.com
<directory "/Users/myusername/Sites/jaxersite2">
JaxerFilter .html .xhtml .htm .php
JaxerFilterContentType text/html application/xhtml+xml


This small change alone freed me from having to start Jaxer with the system. Now, I can simply open the Jaxer Launcher application and fire up Jaxer when I am ready to code and test.

It's a small thing and, perhaps, not worth the extended post but I felt compelled to blog it in the event that someone learning about Apache and/or Jaxer might find it useful. For me, it was an important realization of what you can configure in a VirtualHost element (yes, I really should read the Apache documentation sometime!!).

Now, if I could only get Tomcat to 'see' my UrlRewriteFilter JAR/Class file so that I can finish with connecting it to my default Apache instance :)!

Comments