Archive for January, 2008
Coolest Const Ever
This line is from one of the Silicon Graphics’ GLU tutorials — and is probably one of the most awesome C preprossesor lines ever written:
#define NUM_SHARKS 4
Triple Click
Did you know that there is such a thing as a triple-click? I had been doing it for years in the Firefox URL bar without really noticing it to highlight the entire URL. It turns out that in most text display contexts, triple-clicking a line will highlight it. Go figure!
No commentsHome Sweet Home
Hi! You are reading this, which means you’ve found the new location of my blog.
Did you find it by accident? Or did I push this on you? Are you wondering what this will do to your life now, having to skim through long, uninteresting rants out of a vague sense of obligation to a guy you don’t really hear from? Just know that others have gone through the same experience, and that you are not alone. I hear that a support group will be forming soon, with monthly potlucks and plenty of tissues.
No commentsApache Logs in Leopard
In case you were wondering, O wayward Googler, you can find the apache logs for Leopard under /var/log/apache2. You’ll probably be interested in:
/var/log/apache2/access_log
/var/log/apache2/error_log
Installing Apache Tomcat 6 on OS X
Apache Tomcat is an open source web framework (or “servlet container”, in javaverse lingo) for deploying JSP-powered web applications. I needed to get a local copy running on my PowerBook in order to develop a better search engine for Molsoft’s ICM documentation pages– more on that later. At the end of this guide, you should have a complete Tomcat installation running with the manager application enabled.
Warning: There’s a great, but deprecated, tutorial on ADC that this guide borrows heavily from. That said, I do not advise following the ADC tutorial, as the setup of Tomcat has changed a great deal between the version in use at the time of the tutorial’s writing in 2001 (4.0.1) and the current version (6.0.14).
Okay, let’s get going. First, grab a copy of the latest tomcat 6.x tarball .
We’re going to check the md5sum of the downloaded tarball just to make sure we got what we ordered. I neglected to do this on the first go-round, and ended up with a distribution that was missing the manager webapp. Figures.
md5 apache-tomcat-6.0.14.tar.gz
Make sure the md5 hash that this command spits out is the same as the one provided next to your download link. If it’s not, try another mirror.
Extract the tarball in your /usr/local/ directory, or to wherever you want to install Tomcat.
sudo sh
mv apache-tomcat-6.0.14.tar.gz /usr/local/
cd /usr/local
tar zxvf apache-tomcat-6.0.14.tar.gz
rm apache-tomcat-6.0.14.tar.gz
Let’s go ahead and change the ownership of the tomcat directory so that we don’t have to type sudo anymore.
chown -R [user]:staff apache-tomcat-6.0.14
Hey, you have a fully functional Tomcat install on your system now! Let’s write some control scripts to get it running. (This is where we begin to depart from the ADC tutorial… Note that the JRE install location has changed.)
cd
mkdir bin
cd bin
Edit a file called tomcat_start in this directory, and copy the following lines into it:
#!/bin/sh export CATALINA_HOME=/usr/local/apache-tomcat-6.0.14 export JRE_HOME=export CATALINA_HOME=/usr/local/apache-tomcat-6.0.14 export JRE_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home $CATALINA_HOME/bin/startup.sh
Save tomcat_start. Now edit a new file, stop_tomcat, with the following lines:
#!/bin/sh export CATALINA_HOME=/usr/local/apache-tomcat-6.0.14 export JRE_HOME=export CATALINA_HOME=/usr/local/apache-tomcat-6.0.14 export JRE_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home $CATALINA_HOME/bin/shutdown.sh
Save this file, too. Now make both files executable:
chmod +x start_tomcat stop_tomcat
And go ahead and start Tomcat.
./start_tomcat
Open http://localhost:8080/ in your browser and you should see a nice, locally served Tomcat page that should look something like this:

That wasn’t so hard. Let’s roll up our sleeves and fire up the web interface for the manager application to do our first install: http://localhost:8080/manager/html/.

Whoops! 404. Looks like we’ve got some configuring to do. It’s not too bad, though. All we have to do is add a user to the tomcat-users.xml file located under /usr/local/apache-tomcat-6.0.14/conf. Add the following line in between the “tomcat-users” tags with your own username and password:
<user username="admin" password="secret" roles="standard,manager"/>
Save the file and exit. We now need to restart tomcat in order for our configuration change to take effect. Let’s stop and start our server:
~/bin/stop_tomcat
~/bin/start_tomcat
Now Reload http://localhost:8080/manager/html/ and you should get something similar to this:
Now you’re set up with a fully functional Tomcat install. If you’re ready for more, try plumbing the depths of the Tomcat documentation for the 6.x series. It’s a bit aimless, but it’s very informative and worth a careful read. The Application Developer’s Guide is a good place to start.
EDIT: Special thanks to Pete Ludwig for pointing out the necessary restart after the change to tomcat-users.xml.
If you’re really interested in getting a solid understanding of both the particulars of the tomcat framework AND learning the JSP system thoroughly, think about getting yourself a copy of “How Tomcat Works” by Budi Kurniawan and Paul Deck. Don’t let the title turn you off; this book contains thorough treatment of not only Tomcat, but JSP and servlet programming in general. 2 comments
