Railo and Resin for a New Website on a Mac in 5 Minutes
Firstly, in terminal I just did an "sudo apachectl restart" just to make sure Apache was installed and running (it was).
I wanted to put together a specific website on Railo, so I went into terminal and typed: "mate /etc/hosts". If you don't use textmate, get it! If you *really* don't want to get it, you could replace the editor name or just use the finder to go to the Etc directory and edit the hosts file using your text editor of choice. I added a line:
127.0.0.1 myproj.local
Hit save, entered my system password, and now I have a new host header so myproj.local points to my machine.
Then I added a vhost in Apache for the site. I went into "mate /etc/apache2/httpd.conf" and just confimed that it had an include for "/private/etc/apache2/extra/httpd-vhosts.conf" (just apple-F "vhosts" to find the string). It did. I also checked to see whether I had any jrun code like the following:
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore /Applications/JRun4/lib/wsconfig/1/jrunserver.store
JRunConfig Bootstrap 127.0.0.1:51020
#JRunConfig Errorurl url <optionally redirect to this URL on errors>
#JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying to reconnect to unreachable clustered server>
#JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connect to a jrun server>
#JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive to a jrun server>
#JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a jrun server>
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>
If you do, you'll want to remove that from the httpd.conf and to put it into the specific vhosts that want to use jrun rather than making it server wide.
Then I closed httpd.conf and opened the vhosts file "mate /etc/apache2/extra/httpd-vhosts.conf" and added a vhost pointing to my new project web root:
ServerName myproj.local
DocumentRoot "/Library/WebServer/Documents/myproj/www"
</VirtualHost>
I saved and then "sudo apacheclt restart" to reload apache with the new configuration. To check this was working, I entered "sudo apachectl -S" to see the status of the vhosts to check my configuration.
I then went to download Railo selecting the "Railo Server" - all OS ZIP file (currently railo-3.1.0.012-resin-3.1.2-without-jre.zip (41 MB)). I downloaded Railo and put it somewhere on my Mac. You can put the file anywhere. I've used anything from my user root directory to /opt (optional installs using a common Unix convention) or /usr/local (which is also where mysql typically installs) to adding a server directory to Application. I unzipped the file, renamed the unzipped directory as "railo" and put it into /usr/local.
I then had to check Railo was running, so in /usr/local/railo/bin I opened terminal and typed "./httpd.sh" to run Resin. It started up on port 8600 (check the terminal output near the top to see the port) so I went to
http://myproj.local:8600/
to confirm it was displaying OK and got the Railo default demo link and dump showing the site was up and running on port 8600.
Next I had to set up Resin to point to my new website for myproj.local requests. To do that I went into /usr/local/resin/conf and opened resin.conf (anywhere just enter "mate /usr/local/railo/conf/resin.conf"). Around line 252 you should find something like:
<host id="" root-directory=".">
<!--
- configures an explicit root web-app matching the
- webapp's ROOT
-->
<web-app id="/" root-directory="webapps/ROOT"/>
<web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
<!--
- Administration application /resin-admin
-
- password is the md5 hash of the password.
- localhost is true to limit access to the localhost
-->
<prologue>
<resin:set var="resin_admin_password" value=""/>
<resin:set var="resin_admin_localhost" value="true"/>
</prologue>
</web-app>
Replace that with:
<web-app id="/" root-directory="/Library/WebServer/Documents/myproj/www"/>
</host>
where root directory is the web root for your site. To test this is working, go to http://myproj.local:8600/ to confirm that Resin is displaying the site correctly.
Now the final step is to get Apache forwarding to Resin for the site. Go back to the vhosts file and add the following to the vhost:
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://myproj.local:8600/
ProxyPassReverse / http://myproj.local:8600/
So the vhost for your project should now be something like:
ServerName myproj.local
DocumentRoot "/Library/WebServer/Documents/myproj/www"
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://myproj.local:8600/
ProxyPassReverse / http://myproj.local:8600/
</VirtualHost>
Then restart apache to reload the config "sudo apachectl restart" and go to http://myproj.local and apache will now proxy the request to resin which will serve up your same website, but now you can use URL rewriting or any of the other goodness from Apache.



ProxyPreserveHost On
to your vhosts file.
If you don't do this, you'll just get the server_name as localhost. So now your vhosts should look something like:
<VirtualHost *:80>
ServerName myproj.local
DocumentRoot "/Library/WebServer/Documents/myproj/www"
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://myproj.local:8600/
ProxyPassReverse / http://myproj.local:8600/
</VirtualHost>