Prepare Grails hosting: Apache + Tomcat
Posted by admin - 26/07/09 at 11:07:20 pmMy last weekend I spent fighting with my VPS, try to configure it to host Grails applications on Tomcat server. Because there are some applications writed in PHP already on it, there is no way to bring tomcat on the front (port 80). Only way is to use Apache2 server as a proxy for Tomcat.
Our work we start from installing Apache HTTP Server (v. 2.2):
sudo apt-get install apache2
Next step is to install Apache Tomcat. To avoid problems after apt-get tomcat installation, try this tutorial.
Now we ready to download mod_jk that will act as bridge between two servers
sudo apt-get install libapache2-mod-jk
now configure it:
/etc/apache2/mods-available/jk.conf
JkWorkersFile /etc/apache2/workers.properties JkLogFile "|/usr/sbin/rotatelogs /var/log/apache2/mod_jk.log 86400" JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkRequestLogFormat "%w %V %T" JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
/etc/apache2/workers.properties
worker.list=tomcat6 worker.tomcat6.type=ajp13 worker.tomcat6.host=localhost worker.tomcat6.port=8009
and create link to jk.conf:
ln -s /etc/apache2/mods-available/jk.conf /etc/apache2/mods-enabled/jk.conf
Now we may configure virtual host in Apache:
<virtualHost *:80> ServerName grailsappliaction.com LogLevel warn ServerSignature On JkMount /* tomcat6 </virtualHost>
and set tomcat host (conf/server.xml):
...
<host name="grailsappliaction.com" appBase="/path/to/grails/app">
...
Deploy your grails application in appBase as default (ROOT) application and restart Apache and Tomcat. Your application should be online now.
You may removed this line from tomcat server.xml file, to avoid direct request on 8080 port:
...
<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
...
If there is better way to configure Apache and Tomcat, please let mi know.
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.