[CF] [pl] Wiele silników CF na jednej maszynie [en] Many CFML engines on one machine
by jmail on Jun.06, 2010, under PHP / CF / .NET / Java
Of course every one knows that when you creating a CFML app then you must or you want to test it on many CFML engines. So what we do today is to create a testing enviroment for many CFML engines. At the end of this road you’ll get the running testing enviroment!
Good news is that you don’t have to test on IIS nothing else then a Adobe ColdFusion from installer. Why? Because that is the only instance which is not running through the Java container. In fact it runs. But it’s strange. Trust me that that is the only thing you need to do with IIS.
If you’ve got Windows Server system you can feel lucky. You can easily install ACF7 ACF8 ACF9 on one IIS. (This article wont be about installing ACF on IIS). If you’ve got only XP or Vista or Seven Windows check this tutorial many sites on IIS in Windows XP and just do it! I don’t need to test my apps on IIS (but I’ve got CF7, CF8 and CF9 on server – developers edition).
Second good information is that the only thing you have to test is one servlet container. Why? Because it’s not depend on the servlet container. It depends on JDK and JRE that you are using!
First bad news is that behave of Apache + Resin can be a little bit strange from other typical servlet container. Nevermind. We will try to do this as well.
The second bad news is that you need some free disk space. I don’t know exactly how much but I think that 1GB will be enough. Why? Think! We will install Railo 3.1.2, Open BlueDragon and ACF 9 (If you need other versions look at docs). Because of the disk space at my computer, everything will be prepared to run on disk D (I’ve got free space on this disk
). At the package there will be information how to simply change the default location of you testing enviroment.
We will make testing enviroment based on Tomcat and Resin. At the front of servlet containers there will be Apache from XAMPP package. Oh yes. I will prepare a package for you with whole production use ready to start by couple clicks!
Of course you can use Jetty for it or JBoss or anything else you want, but I won’t support this baceaus I don’t know those containers! I am trully sorry but I can’t give you the package with GlassFish. I haven’t still figured out how to run railo or acf on the GlassFish as a module not an app.
0. Preparation
We need some preparations.
A/ make CFMLTestingEnviroment dir on disk D – I will call this rootDir
B/ in this dir create dirs
- SourceRepo
- Source
- Sites
– ACF9Test
– OBDTest
– RAILOTest
– RailoResinTest
– ACF9IISTest
- Batches
- ServletsContainers
– ACF9Test
– OBDTest
– RAILOTest
– RailoResinTest
- XAMPP
C/ Open C:\Windows\system32\drivers\etc\hosts file and add to it
#CFMLTestingEnviroment
127.0.0.1 ACF9Test
127.0.0.1 OBDTest
127.0.0.1 RAILOTest
127.0.0.1 RailoResinTest
127.0.0.1 ACF9IISTest
And the last thing. We will configure everything like that:
- Tomcat + Railo 3.1.2 – port 8200
- Tomcat + ACF9 – port 8201
- Tomcat + OBD – port 8202
- Resin + Railo 3.1.2 – port 8203
1. Apache
As I metioned before the front of the testing system will be Apache. So first we need to get this. The easiest way to get the Apache is to get the XAMPP Light edition from XAMPP site – XAMPP
A/ Download the zipped version and just extract everything into rootDir/XAMPP path
B/ Go to the rootDir/XAMPP/apache/conf/httpd.conf file and open it in notepad
C/ Change ALL occurrences of
/xampplite/
to
rootDir/XAMPP/
NOTE:
Be very carefull in changing that because if you find
/xampplite/apache/htdocs
then you MUST change it to
rootDir/Sites
D/ Go to rootDir/XAMPP/php/php.ini and edit it
E/ Change ALL occurrences of
\xampplite\
to
rootDir\XAMPP\
F/ Execute your rootDir/XAMPP/apache/httpd.exe (command line will come – don’t close it!)
G/ Go to your http://localhost/ site and you should seen directories
- ACF9Test
- OBDTest
- RAILOTest
- RailoResinTest
- ACF9IISTest
If so you’ve got your testing Apache configured. Hmmmm almost :F Now stop Apache Ctrl+C
2. Resin + Railo
First we will try to install Resin as a container for Railo and try to run this via mod_caucho module.
A/ Download Resin 3.1.9 (on Railo site that is still recomended version)
B/ Put all files from resin pack into rootDir/XAMPP/ServletsContainers/RailoResinTest
C/ Go to rootDir/XAMPP/ServletsContainers/RailoResinTest/conf/resin.conf and edit it
D/ Change
1 | <http address="*" port="8080"/> |
to
1 | <http address="*" port="8203"/> |
D/ Go to the GetRailo and download jars package. Save it somwhere – we will need this also on tomcat installation
E/ Follow the instruction just leave steps where you are configuring Apache and adding host – we will make this later.
F/ Start Resin by execute rootDir/ServletsContainers/RailoResinTest/httpd.exe
G/ Go to http://localhost:8203/railo-context/admin/server.cfm Resin is done
H/ Stop resin
3. Connecting Resin with Railo
We don’t want to make Resin+Railo default cfml parse engine so we must configure virtual host for this instance of CFML Engine
A/ Go to rootDir/XAMPP/apache/conf/extra/httpd-vhosts.conf end edit it. Clear whole file and add there:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "rootDir/Sites" ErrorLog "logs/error.log" </VirtualHost> LoadModule caucho_module "rootDir/ServletsContainers/RailoResinTest/win32/apache-2.2/mod_caucho.dll" <VirtualHost *:80> DocumentRoot "rootDir/Sites/RailoResinTest" ServerName RailoResinTest ErrorLog "logs/RailoResinTest-error.log" DirectoryIndex index.cfm index.php index.htm index.html index.html.var ResinConfigServer localhost 6800 <Location /caucho-status> SetHandler caucho-status </Location> </VirtualHost> |
B/ Go to rootDir/Sites/RailoResinTest create simple index.cfm file and put in it
1 2 3 4 | <cfset test = "Hello world"> <cfoutput> #test# </cfoutput> |
C/ Go to rootDir/ServletsContainers/RailoResinTest/conf/resin.conf edit it and add it in right place (in about 311th linie)
1 2 3 4 | <host id="RailoResinTest" root-directory="rootDir/Sites/"> <web-app id="/" root-directory="RailoResinTest"> </web-app> </host> |
C/ Run Resin, wait for start. Run Apache
D/ Go to http://railoresintest/ – you should se Hello World
Stop Apache and Resin.
4. Multi Tomcat instances
We will build our testing enviroment on three Tomcat instances. It’s quite easy to prepare
A/ Download Tomcat 6.0.26 zip package and uznip it – Tomcat
B/ Copy all files from packge into
- rootDir/ServletsContainers/ACF9Test
- rootDir/ServletsContainers/OBDTest
- rootDir/ServletsContainers/RAILOTest
C/ Tomcat is listennig on two ports – one http protocol (usualy 8080) and second for shutdown (usualy 8001). SO we must change them.
for easiest I will use tomcatPath as I am mentione about any of three paths to tomcat
D/ Go to every tomcatPath/conf/server.xml file edit it and change port
- 8005 to:
a/ 8300 for Railo
b/ 8301 for ACF9
c/ 8302 for OBD
- 8080 to:
a/ 8200 for Railo
b/ 8201 for ACF9
c/ 8202 for OBD
- 8009 to:
a/ 8400 for railo
b/ 8401 for ACF9
c/ 8402 for OBD
E/ In the same file (server.xml) add at the end of the file (before )
For Railo
1 2 3 | <Host name="RAILOTest" appBase="webapps"> <Context path="" docBase="rootDir/Sites/RAILOTest"/> </Host> |
For ACF9
1 2 3 | <Host name="ACF9Test" appBase="webapps"> <Context path="" docBase="rootDir/Sites/ACF9Test"/> </Host> |
For OBD
1 2 3 | <Host name="OBDTest" appBase="webapps"> <Context path="" docBase="rootDir/Sites/OBDTest"/> </Host> |
F/ Go to the tomcatPath/bin/startup.bat and run three instances of Tomcat. Command windows will be opened.
G/ To check everything is OK go to
- http://localhost:8200
- http://localhost:8201
- http://localhost:8203
So we’ve got three instances of Tomcat. Now we are going to make them running CFML engines
5. Tomcat + Railo
I have made article about building Tomcat with Railo. You can find it in here Apache + Tomcat + mod_rewrite + mod_proxy
6. Tomcat + OBD
I don’t like Open Blue Dragon but maybe you will test application against that engine. Maybe just because that the interface is weak?
A/ Download and unzip OBD from Open Blue Dragon web site
B/ Copy files into rootDir/Sites/OBDTest
C/ Open rootDir/Sites/OBDTest/WEB-INF/web.xml
D/ Add (on servlet mappings area)
1 2 3 4 5 6 7 8 | <servlet-mapping> <servlet-name>cfmServlet</servlet-name> <url-pattern>/index.cfm/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>cfmServlet</servlet-name> <url-pattern>/rewrite.cfm/*</url-pattern> </servlet-mapping> |
works
7. Tomcat + ACF9
Adobe ColdFusion is the major CFML Engine. I will integrate Developer’s edition with Tomcat.
A/ Donwload CF9 exe file from Adobe
B/ Start the installer
C/ On configure installer page choose J2EE Configuration and choose WAR file
Note: If you don’t need then don’t install any other ACF services
D/ Wait untill it stops installing.
E/ Hell it’s heavy! 248MB :/ And 314 after unpack :F
F/ Unpack war file. Copy all files from inside into rootDir/Sites/ACF9Test
G/ Find begin SES comment in rootDir/Sites/ACF9Test/WEB-INF/web.xml
and add before this comment
1 2 3 4 5 6 7 8 | <servlet-mapping id="coldfusion_mapping_6"> <servlet-name>CfmServlet</servlet-name> <url-pattern>/index.cfm/*</url-pattern> </servlet-mapping> <servlet-mapping id="coldfusion_mapping_7"> <servlet-name>CfmServlet</servlet-name> <url-pattern>/rewrite.cfm/*</url-pattern> </servlet-mapping> |
works
8. Making Apache able to translate redirects
Everything was quite eqsily described in article Apache + Tomcat + mod_rewrite + mod_proxy so I just put in here the config to add for vhosts. Make everything is needed about proxying and rewriting in that article
A/ Open rootDir/XAMPP/apache/conf/extra/httpd-vhosts.conf
B/ Add at the end of the file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <VirtualHost *:80> ServerName RAILOTest ServerAlias RAILOTest DocumentRoot "rootDir/Sites/RAILOTest" DirectoryIndex index.cfm <Directory "rootDir/Sites/RAILOTest/"> Options -Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> RewriteEngine On <LocationMatch "^[^/]"> Deny from all </LocationMatch> ProxyRequests Off ProxyPass / http://RAILOTest:8200/ ProxyPassReverse / http://RAILOTest:8200/ ProxyPreserveHost On RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|sitemap.xml|rewrite.cfm)($|/.*$) [NC] RewriteRule "^/(.*)" http://RAILOTest:8200/rewrite.cfm/$1 [P,QSA,L] </VirtualHost> <VirtualHost *:80> ServerName ACF9Test ServerAlias ACF9Test DocumentRoot "rootDir/Sites/ACF9Test" DirectoryIndex index.cfm <Directory "rootDir/Sites/ACF9Test/"> Options -Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> RewriteEngine On <LocationMatch "^[^/]"> Deny from all </LocationMatch> ProxyRequests Off ProxyPass / http://ACF9Test:8201/ ProxyPassReverse / http://ACF9Test:8201/ ProxyPreserveHost On RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|sitemap.xml|rewrite.cfm)($|/.*$) [NC] RewriteRule "^/(.*)" http://ACF9Test:8201/rewrite.cfm/$1 [P,QSA,L] </VirtualHost> <VirtualHost *:80> ServerName OBDTest ServerAlias OBDTest DocumentRoot "rootDir/Sites/OBDTest" DirectoryIndex index.cfm <Directory "rootDir/Sites/OBDTest/"> Options -Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> RewriteEngine On <LocationMatch "^[^/]"> Deny from all </LocationMatch> ProxyRequests Off ProxyPass / http://OBDTest:8202/ ProxyPassReverse / http://OBDTest:8202/ ProxyPreserveHost On RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|bluedragon|robots.txt|sitemap.xml|rewrite.cfm)($|/.*$) [NC] RewriteRule "^/(.*)" http://OBDTest:8202/rewrite.cfm/$1 [P,QSA,L] </VirtualHost> |
C/ Start Resin, Railo Tomcat, ACF9 Tomcat, OBD Tomcat. Wait untill containers starting. Start Apache.
D/ voile’a It works!
http://railotest/
http://acf9test/
http://obdtest/
9. One code – 5 instances
I assume that we’ve got four instances on Apache and one instance on IIS (configure IIS to access to get site from rootDir/Sites/ACF9IISTest/). So now wee need to make something easier. Redistribute the code to every containter.
We will use the power of Subversion.
A/ Get Subversion and TortoiseSVN ( you can use any other versioning system but I won’t support this – I like SVN
)
B/ In rootDir/SourceRepo create an SVN repository
C/ Go to rootDir/Sites and for every each testsite checkout created repo
D/ in every each directory remove cfm jsp or other files that are not needed
E/ Commit directory by directory and add all needed files into ignored list
F/ Go to rootDir/Source and checkout the repo
G/ rootDir/SourceRepo/hooks and add post-commit.bat file
H/ put in it
1 2 3 4 5 | svn update "rootDir\Sites\RAILOTest" svn update "rootDir\Sites\ACF9Test" svn update "rootDir\Sites\OBDTest" svn update "rootDir\Sites\RailoResinTest" svn update "rootDir\Sites\ACF9IISTest" |
that’s all. Now if you put anything into the Source folder and commit that you will get the test unit on 5 instances
10. So how about Wheels on source
I have put there 1.0.4 Wheels
in .htaccess file I have uncommented rewrite rules (as you saw we’ve got those rules on vhosts conifg files) and set urlRewrite to enforce the URL Rewriting
11. Batches
In Batches dir I have prepared two usefull .bat files for easy start the test unit.
First start the StartCFMLInstaces.bat this will up all instances
Then run StartApache.bat which will up the apache
So I think that’s is surely enough – I am dying
Right now the package is being packed and uploaded so I give you the link when this will be finished.
Yeah and I have almost forgotten. The every password you’ll need to type is abc123
And you have to know that packed package got 234 MB.
You can download the package from my site
have a nice day to everyone.
