I observed that there is no full guide for installing tomcat on OS X that will include setting it up to start at boot time.
Here is the quick guide:
- install macports
suport port upgrade
sudo port upgrade outdated
.
sudo port install tomcat6
, or if you want other version checkport list|grep tomcat
- config is now at:
/opt/local/share/java/tomcat6/conf
startup script:
/opt/local/share/java/tomcat6/bin/tomcatctl
cp /opt/local/share/java/tomcat6/conf/tomcat-users.xml.sample /opt/local/share/java/tomcat6/conf/tomcat-users.xml nano /opt/local/share/java/tomcat6/conf/tomcat-users.xml
... check article
But I'm missing the part on how to make it run as true service/daemon: at system startup and optionally to make it restart if it does crash.
This is for installing tomcat as a daemon on port 8080 but enable also port 80 by using a firewall redirection. It was tested on Mac OS 10.6 but should work also with 10.5.
Edit
/opt/local/share/java/tomcat6/conf/server.xml
and addproxyport="80" URIEncoding="UTF-8"
inside<Connector .../>
.For forwarding port 80 to 8080 run this line and add it do
/bin/catalina.sh
:Assign enough memory to the Java machine or you may be in trouble later. Inside
/opt/local/share/java/tomcat6/conf/local.env
In my example I allocated ~3Gb or RAM but you can adapt this, anyway don't put less than 1GB if you are running
hudson
inside tomcat.Running as a service
Run
nano /Library/LaunchDaemons/org.apache.tomcat.plist
and paste the code below:Check that launchd detected you new daemon, if not reboot :(
Start tomcat manually.
If the status is something else than
-
, you have a problem and you should investigate it:launchctl log level debug
and check/var/log/system.log
.You need to register tomcat as an item that needs to be executed on startup. On Mac OS, this is handled by launchd (http://developer.apple.com/macosx/launchd.html). I don't know if launchd supports auto restarting, but otherwise you should have a look at something like supervisord (http://supervisord.org/).
For Snow Leopard launch on startup I created a plist file in /Library/LaunchDaemons/ The plist file will look like this (below, amend to match your directories). You can start/stop the service for testing by issuing "launchctl load org.macports.tomcat6.plist" or "launchctl unload org.macports.tomcat6.plist". Once you have it working reboot to prove the autostart at boot.