miracle occurs here|

Archive for November, 2008

Change Apache DocumentRoot on Mac

Saturday, November 22nd, 2008

I was trying to configure Apache on my Mac to better incorporate it into my desktop development environment. Part of that included customizing the DocumentRoot location – changing it from the default directory (/Library/WebServer/Documents) and pointing (or linking) it to a directory that just made more sense to me. But it wasn’t as easy as I expected.

Trouble was, I couldn’t get Apache to reflect my changes to the Apache configuration file (httpd.conf), regardless of how many times I restarted Apache (via System Preferences). Finally I did a find (find /etc/ -name "httpd.conf") and figured out that I was editing the wrong configuration file (/etc/httpd/httpd.conf). My Mac was actually running Apache v2, but I was editing the configuration file for the now defunct (but apparently still present) Apache v1 installation. So I edited the correct configuration file (/etc/apache2/httpd.conf), restarted Apache as before, and everything worked as expected. :)

If you enjoyed this post, you might want to follow this blog!

mod_jk Fail, mod_proxy Success

Friday, November 14th, 2008

I have a production site configured with Apache2 forwarding requests to Tomcat using mod_jk. I wanted to mimic this configuration on my desktop environment, but was not able to get it to work locally on my Mac. I ended up using mod_proxy locally instead. This is the ordeal I went through…

I grabbed a binary for Mac OSX (x86) from the Tomcat Connectors site, renamed it to mod_jk.so, and dropped it in the directory with the other modules. I made the necessary changes and additions to the Apache config files. Unfortunately, when I started Apache, I received the following error:

no suitable image found.  Did find: /usr/libexec/apache2/mod_jk.so:
mach-o, but wrong architecture

Googling the error helped me realize that I wasn’t alone with my issue and I figured out that I needed to build mod_jk from source, passing in some special flags to the build:

./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64'
-with-apxs=/usr/sbin/apxs

This was great, but the next step (i.e., “make”), kept failing for me:

jk_global.h:66:21: error: apr_lib.h: No such file or directory
jk_global.h:67:25: error: apr_strings.h: No such file or directory
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1

I found lots of other pages explaining further variations of the same basic premise that I needed to build from source:

I followed all of these instructions, but still had no luck. Then I tried going down the DarwinPorts path:

But I didn’t get anywhere with this:

mike$ sudo port install mod_jk
...
Configuring APR library
Platform: i386-apple-darwin9.4.0
checking for working mkdir -p... yes
APR Version: 1.3.2
checking for chosen layout... apr
checking for gcc... /usr/bin/gcc-4.0
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.

I came to suspect that I might require an install of Apple’s Xcode to get any of these solutions to work. So I started downloading it. As I was waiting for the download to complete, I started looking at mod_proxy as an alternative to mod_jk. Using mod_proxy wouldn’t accomplish my goal of mirroring the production configuration and I wasn’t sure if it could handle sticky sessions, but I didn’t need that at this point. So I gave it a whirl, fought with it a little bit, and eventually was able to configure a solution before I got anywhere with Xcode:

In Apache’s httpd.conf:

<Proxy balancer://myCluster>
   BalancerMember ajp://dev.milestoneinc.com:8010 route=node1
</Proxy>

ProxyPass /blogs !
ProxyPass /balancer-manager !
ProxyPass / balancer://myCluster/ stickysession=JSESSIONID

<Location /balancer-manager>
	SetHandler balancer-manager
</Location>

In Tomcat’s server.xml:

<Engine defaultHost="localhost" jvmRoute="node1" name="Catalina">

More information regarding mod_proxy and load-balancing/session-affinity:

If you enjoyed this post, you might want to follow this blog!

Here be Miracles

Tuesday, November 4th, 2008

This blog is Milestone’s (meaning – Michael Scepaniak’s) attempt to give something back to the open-source software community. My evolution as a software developer started right about the same time the Web began to blossom, Java gained traction, and open-source software initiated its march toward ubiquity.

Without open-source software (specifically open-source software frameworks and components) such as the Spring Framework, Hibernate, Jakarta Commons, Tomcat, HtmlUnit, Freemarker, Linux, and others, I suspect that software development would be an immensely frustrating, passion-less chore. What open-source software brings to the table is creative, inspired, developer-focused solutions to real, trench-level problems and inefficiencies. It spurs openly-accessible, internet-wide discussion and peer-based support amongst a large community of geographically-isolated individuals.

I, like countless other software developers the world over, have benefited greatly from such software, both professionally and personally (not to mention monetarily). The effort required to build open-source software is significant, second only to the effort required to publish it, maintain it, test it, document it, and support it. The fact that the users of that open-source software (meaning, other software developers) tend to be a demanding, critical lot makes this effort even tougher.

I have massive amounts of respect for open-source software developers and everyone that contributes to fostering the ecosystem. With this blog, I hope to become a more meaningful participant of that ecosystem – more than simply a consumer.

I don’t expect to earn any oohs or aahs with this effort. It’ll simply be me sharing tips and tricks and know-how and workarounds that I have picked-up over my years doing software development. I don’t expect it to be the sort of blog to which people feel compelled to subscribe. Rather, I hope it becomes something that software developers stumble across when desperately googling for a solution to whatever gotcha’ they’ve found themselves caught in – a solution that I’ve already managed to figure out at some point in the past.

At the deepest, darkest point of maximum frustration, even a simple answer can seem like a miracle.

If you enjoyed this post, you might want to follow this blog!