Setting up your multiengine environment Apache Railo ColdFusion
-
Upload
coldfusionconference -
Category
Software
-
view
490 -
download
4
description
Transcript of Setting up your multiengine environment Apache Railo ColdFusion
Se#ng up your mul.---engine environment Apache, Railo and ColdFusion
Presented by Gavin Pickin Slides: http://gpickin.com/cfo2014/ Website: http://gpickin.com Twitter: @gpickin
Introduc)on
• Follow along with resources from h6p://gpickin.com/cfo2014/
• Lots to cover today, so lets get moving.
• If you want to find out more about me, my website has more than enough informa)on
Agenda
• Why would you want a mul)---engine environment?
• Overview of How to Setup Mul)ple Engines with Apache
• Which versions of ColdFusion – 9, 10, 11 Beta
Why would you want a mul) engine environment?
• Not all servers are running the same CF Engine. You might need to support mul)ple versions / plaUorms.
• Migra)on tes)ng for versions, and or plaUorms, CF vs Railo
Why would you want a mul) engine environment? cont
• Running mul)ple sites out of CF Root directory using subfolders has its issues
– Shared mappings means less flexibility in which framework versions etc you use
– Your code and paths have to allow for subfolders
– Using port numbers means you have to remember more
Why Apache
• Apache is supported on Linux, Windows and Mac OSX – Cross plaUorm + text configura)on
• Apache is a tried and true, trusted Web Server
• Apache can act as your Controller and pass the requests to the appropriate engine
Multi Engine Overview
myclient.local.com
html, js, css, images
Apache passes the request based on URL
CF10
(f
CF9
CF11 Railo 4
•
•
• val ••
Apache Configuration
APACHE I r P RV""r
httpd.conf
Ho Edll OptiOnS Butrers Tools He p
• Load conhq hlu froa the conhq cluctory "/etc/httpcl/conf d"
tnchwlt cont d/' conf Include /usr/local/nocat/auth•erv/httpd eonf
•• EXUndodStatu> tontrol.t vhotber Apache v1ll goonoru.e "full" otat.uo • nforaot1on (b ndodStoto.oo On) OT ) ot bone info110.0t>0n (txten4od5toto.oo • Off) vhen the •server-stotus• hand.Ur •• e..U.d '!he defeult u Off •#Ext<lndedSta.tuo On
,,. Seet1.on 2 ···.aecver configurat1.on
• 'Iho duect1voo tbu oect•on .. t up the v eo . .d by tbe 'ao>n' • :5etvervh.u.b. tetpO'tUb t.o any tequt'-U that &tV\' t bandle4 by a • <VHW&Uioot> dehmt1on 'lhooo oloo prov>de defeulto for • any <Vlttualiloot> eonta.>nero you aoy dehn.e Later '" tbe hle 6 All of these cht Ct1Ye.a ••Y "9'()8a..t 1.1\alde <VUt.u.tB.ost> COl'lt.a.l.MU, • >n vh1ch cue tbooo dofeult oott1ngo v1ll be overud.den for the ;vub14l hoot bung dehnd
··" ""'""·-r ··Ll9!>2-1·1t · ··· · ················· ·-J L!.!
www.
Global Settings General Global Settings for all websites running on the server.
Load Module Loads the module and is available for every request. Cannot be loaded inside Virtual Host
Virtual Hosts Settings for each Website on the webserver. Override settings for logs, aliases I mappings etc
Install + Configure Apache
• View my Presenta)on Site for Links and resources
• Ac)vate VirtualHost by Uncommen)ng NameVirtualHost in h6pd.conf or virts.conf
• Use ‘Include’ to point to central configura)on folder.
Central Config Folder
• Keep all your ever changing files together in one loca)on for ease of access, git version control, and automa)on op)ons.
• {WebConf} --- Folder
– Apache --- Folder holds all the virts conf files
– Inc_cf*_module.inc – Code that loads the module
– Inc_cf*_conn.inc – Code that uses the module
– Inc_railo_hosts.xml – XML Virtual Hosts for Railo
Connec)ng to Apache
• Whenever you install a CFML Engine, you have the op)on to setup your Web Server to connect.
• Since we want mul)ple engines, we need to make a backup of our h6pd.conf file, and extract those connec)on sefngs so each site can connect to the engine of its choice.
• So we’ll Install, Connect, Extract Code
Installing ColdFusion9, 10, 11
• Resources on my Presenta)on Site
• Highlights
– Setup as single install (easier configura)on)
– Use Built In Webserver DO NOT SETUP WEB CONNECTOR WHEN INSTALLING
– Built in Defaults to 8500 in CF9, and CF10, we’ll need to update the ports to avoid clash. CF11 gives you the op)on to select port during install.
Connec)ng CF* to Apache
• Highlights
– ColdFusion usually creates a backup file, but I make one beforehand just in case.
– Depending on your OS, it is pre6y simple to connect to Apache, Linux you might need to yum more libraries and compile the connector.
– The connector creates files / folders as well as the sefngs in the h6pd.conf itself.
What does CF do when you Connect
• Lets Diff the Original h6pd.conf and the new Connected h6pd.conf
– DirectoryIndex – now has index.cfm added
– Creates a Module, and includes configura)on to Load the Module
– Includes the configura)on op)ons to allow any website on the server to server cfml files.
How do we Extract the Config
# JRun Settings LoadModule jrun_module /www/_servers/coldfusion9/runtimellib/wsconfig/1/modj run22.so
Save into {webconf}/inc_cf9_module.inc
<lfModule modjrun22.c> JRunConfig Verbose false JRunConfig Apialloc false JRunConfig lgnoresuffixmap false JRunConfig Serverstore /www/_servers/coldfusion9/runtime/lib/wsconfig/1{jrunserver.store JRunConfig Bootstrap 127.0.0.1:51011 #JRunConfig Errorurl uri <optionally redirect to this URLon errors> #JRunConfig ProxyRetrylnterval 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> #JAunConfig 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
<llfModule>
Save into {webconf}/inc_cf9_conn.inc
Load Module
Connect using the Module
www.
•
•
•
•
•
•
.:=• J
What do we do after we Extract Config
., -
APACHE
T v = 1
httpd.conf
Include Modules We need to include all the modules we might use on the webserver All modules that our engines,
Fda Ed1l OpbOns Bultrt TOCit& Help
""" Lo.e r nlt.._aaolulu/abd_re-vnte to t.oocblo4W.• prox:y_aodW.e udul. ./aod_pro:xy 10 Le>adJiodule proxy ftp_aodu.Le ao uhtodjto7f:V_ftfJ to
t::=:t: =:; ::.: :0: : 1-bt on:.ct to LoadJiodule eac:h.e aoctu.U iodulet/aoct caeho eo
d9,d10,d11,& railo need.
Include {webconf}/inc_cf9_module.inc Loadllodu.le 1u.eaocllU aodul.e:a/a.oa: aueM Loe duk_eiebe_. .dul.. aoduU>hood >k_eoehe oo
t::=f:!!!:e:h!:.:Oti: _.!! acC: o10
Loe.dXodule C:9J._.clule aodulAtlaoG ' 10
• Load eonh9 h les troa
Incl.wle conf d.J• cont tn.elu.de /uo.c/loc noeat/wthtervlhtt94 eonf
• t:xunded.Ste.tu.t cont.roU vbether be nU CJtnerate ·fW.l" 1t.atu.s • 1nforuuon (txunatdSt.atu• On) or )U.tt ba.nc Woraauon {btt.tNledSutu.t 1Off) when the •aerver-et.e.tua" ba.ndJAr u eal.le-d 'l'be default n Off
or!><too>dodStotu> On ---------------+-+ "'Sect-1on 2 'M•tn' eervec eonhC)Ut.t-101'1
:vtct; ·=::·,! :Ctlon1: :.tb . :.:":i by':Un' # <Yltw.al.Holt> d.-flJUU.OA *- valuu abo prov1d.e d..f.ulu for • at .y <Vutual.Bo-at.> eont&!Aen you. uy clehna latAc 1.n the hle
1 All of these d.iceeuwa uy appn.c 1nnde <VutullBoat > eonUl.tl.eca,
www. Include VirtualHosts Include all of the Virtual Hosts, each Website or Virtual Host will include the inc_d*_conn.inc depending on the engine you want to run in its own .conf
• ·-
-- ------------------------------------
Include {webconf}/apache/*.conf
• 1n wtuch c:u• the,. def.ult tettuw)• v1ll be erndd.en for the 1 vutual boat bu.ng dehne-d
--Ll
Extrac)ng CF9 Connector from Apache
– The connector also created and loads a module for jrun
# JRun Sefngs LoadModule jrun_module /{csome}/run)me/lib/ wsconfig/1/mod_jrun22.so
Extrac)ng CF9 Connector from Apache
• Jrun Module Configura)on • <IfModule mod_jrun22.c> • JRunConfig Verbose false • JRunConfig Apialloc false • JRunConfig Ignoresuffixmap false • JRunConfig Serverstore /{csome}/run)me/lib/wsconfig/1/jrunserver.store • JRunConfig Bootstrap 127.0.0.1:51011 • #JRunConfig Errorurl url <op)onally redirect to this URL on errors> • #JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying to reconn$ • #JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connect to a jr$ • #JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive to a jrun $ • #JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a jrun serv$ • AddHandler jrun---handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf • </IfModule>
Extract CF9 Connector
• Now we need to remove and save the pieces
• Cut the Load Module code # JRun Sefngs LoadModule jrun_module /{csome}/run)me/lib/wsconfig/1/mod_jrun22.so
• Save into a file called /{yourwebconf}/inc_cf9_module.inc
• Cut the remaining connector code and save into file called /{yourwebconf}/inc_cf9_conn.inc
Change CF9 Webserver Port
• Port 8500 will clash with default sefngs for other CF versions, so lets update the port.
• Edit /{csome}/run)me/servers/coldfusion/ SERVER---INF/jrun.xml
• Search for 8500 and you’ll find the defini)on for the jrun WebServer.
– Update Port to 8509 (8500 + version)
– Restart CF9 and its now running on port 8509
Change CF9 Webserver Port
< class=..jrun.servlet.http.WebService.. name=..WebService..> < name=..port..> </ > < name=..interface..>*</ > < name=..deactivated..>false</ > < name=..activeHandlerThreads..>50</ > < name=..minHandlerThreads..>l</ > < name=..maxHandlerThreads..>l000</ > < name=..mapCheck..>0</ > < name=..threadWaitTi.meout..>300</ < name=..backlog..>500</ > < name=..timeout..>300</ >
<I
Extrac)ng CF10 Connector from Apache
• Lets Diff the Original h6pd.conf and the new Connected h6pd.conf
– DirectoryIndex – now has index.cfm added
– The connector added a single line to the end of the h6pd.conf file
– Include "/{apachehome}/mod_jk.conf"
Extrac)ng CF10 Connector from Apache
• # Load mod_jk module • LoadModule jk_module "/{cf10home}/config/wsconfig/1/mod_jk.so" • # Where to find workers.proper)es • JkWorkersFile "/{cf10home}/config/wsconfig/1/workers.proper)es" • JkMountFile "/{cf10home}/config/wsconfig/1/uriworkermap.proper)es" • # Where to put jk logs • JkLogFile "/{cf10home}/config/wsconfig/1/mod_jk.log" • # Where to put jk shared memory • JkShmFile "/{cf10home}/config/wsconfig/1/jk_shm" • # Set the jk log level [debug/error/info] • JkLogLevel info • # Select the )mestamp log format • JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Extrac)ng CF10 Connector from Apache
• AddHandler jakarta---servlet .cfm .cfml .cfc .cfr .cfswf • Alias /CFIDE "/{cf10home}/cfusion/wwwroot/CFIDE" • <Directory "/{cf10home}/cfusion/wwwroot/CFIDE"> • Op)ons Indexes FollowSymLinks • AllowOverride None • Order allow,deny • Allow from all • </Directory> • <Files ~ ".hbmxml$"> • Order allow,deny • Deny from all • </Files>
Extract CF10 Connector
• Now we need to remove and save the pieces • Delete the Line from the h6pd.conf file
include "/{apachehome}/mod_jk.conf”
• Cut the Load Module code from mod_jk.conf From Line # Load mod_jk module To the line JkLogStampFormat "[%a %b %d %H:%M:%S %Y] “
• Save into a file called /{yourwebconf}/inc_cf10_module.inc
Extract CF10 Connector
• Cut the Connector code from mod_jk.conf From line AddHandler jakarta---servlet .cfm .cfml .cfc .cfr .cfswf To line </Files>
• Save into a file called /{yourwebconf}/inc_cf10_conn.inc
Change CF10 Webserver Port
• Port 8500 will clash with default sefngs for other CF versions, so lets update the port.
• Edit /{cf10}/cfusion/run)me/conf/server.xml
• Search for 8500 and you’ll find the defini)on for the jrun WebServer.
– Update Port to 8510 (8500 + version)
– Restart CF10 and its now running on port 8510
Change CF10 Webserver Port
executor="torncatThreadPool" maxThreads="50" port="8510" protocol="org.apache.coyote.httpll.HttpllProtocol" connectionTimeout="20000" redirectPort="8445" />
Extrac)ng CF11 Connector from Apache
• Lets Diff the Original h6pd.conf and the new Connected h6pd.conf
– DirectoryIndex – now has index.cfm added
– The connector added a single line to the end of the h6pd.conf file
– Include "/{apachehome}/mod_jk.conf” Note: this is the same file name as CF10.
Extrac)ng CF11 Connector from Apache
• # Load mod_jk module • LoadModule jk_module "/{cf11home}/config/wsconfig/1/mod_jk.so” • # Where to find workers.proper)es • JkWorkersFile "/{cf11home}/config/wsconfig/1/workers.proper)es" • JkMountFile "/{cf11home}/config/wsconfig/1/uriworkermap.proper)es" • JKIPRestric)onFile "/{cf11home}/config/wsconfig/1/
iprestric)on.proper)es" • # Where to put jk logs • JkLogFile "/{cf11home}/config/wsconfig/1/mod_jk.log”
Extrac)ng CF11 Connector from Apache
• # custom environment variables • JkEnvVar REDIRECT_URL • JkEnvVar REDIRECT_REMOTE_HOST • JkEnvVar REDIRECT_PATH • JkEnvVar REDIRECT_QUERY_STRING • JkEnvVar REDIRECT_HTTP_ACCEPT • JkEnvVar REDIRECT_HTTP_USER_AGENT • JkEnvVar REDIRECT_REMOTE_ADDR • JkEnvVar REDIRECT_SERVER_NAME • JkEnvVar REDIRECT_SERVER_PORT • JkEnvVar REDIRECT_SERVER_SOFTWARE
Extrac)ng CF11 Connector from Apache
• # Where to put jk shared memory • JkShmFile "/{cf11home}/config/wsconfig/1/jk_shm" • # Set the jk log level [debug/error/info] • JkLogLevel info • # Select the )mestamp log format • JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Extrac)ng CF11 Connector from Apache
• AddHandler jakarta---servlet .cfm .cfml .cfc .cfr .cfswf • DirectoryIndex index.cfm • Alias /CFIDE "/{cf11home}/cfusion/wwwroot/CFIDE" • <Directory "/{cf11home}/cfusion/wwwroot/CFIDE"> • Op)ons Indexes FollowSymLinks • AllowOverride None • Order allow,deny • Allow from all • </Directory> • <Files ~ ".hbmxml$"> • Order allow,deny • Deny from all • </Files>
Extract CF11 Connector
• Now we need to remove and save the pieces • Delete the Line from the h6pd.conf file
include "/{apachehome}/mod_jk.conf”
• Cut the Load Module code from mod_jk.conf Fromline # Load mod_jk module To line JkLogStampFormat "[%a %b %d %H:%M:%S %Y] ”
• Save into a file called /{yourwebconf}/inc_cf11_module.inc
Extract CF11 Connector
• Cut the Connector code from mod_jk.conf From line AddHandler jakarta---servlet .cfm .cfml .cfc .cfr .cfswf To line </Files>
• Save into a file called /{yourwebconf}/inc_cf11_conn.inc
Connec)ng Railo to Apache
• My guide is only a starter guide.
• Highlights
– Depending on your OS, the installer can add the connector for you, but not all installers do.
– There are several ways to connect to Railo, mod_proxy, mod_cfml which uses Perl, boncode connector, and simple ajp, which I prefer for single and clusters.
Railo Serves Files Differently
• Railo and ColdFusion differ greatly with how the files are served.
• If you request h6p://localhost/index.cfm and apache’s vhost is /www/localhost/
– ColdFusion will serve /www/localhost/index.cfm
– Railo will serve /{railohome}/webapps/ROOT/ index.cfm
Tomcat Virtual Hosts
• Railo uses Tomcat and it maps the passed URI to its own set of Virtual Hosts.
• ColdFusion’s Tomcat is designed to receive this URI and serve the file from Apache’s path.
• There are pro’s and con’s with flexibility vs simplicity.
• In short – make sure Tomcat’s Vhosts match Apache’s Vhosts
Extrac)ng Railo Connector from Apache
• Since we manually added the AJP code, we can simple cut the code, and save it into a file.
• <Proxy *> • Allow from 127.0.0.1 • </Proxy> • ProxyPreserveHost On • ProxyPassMatch ̂ /(.+\.cf[cm])(/.*)?$ ajp://localhost:8021/$1$2
• Save it into /{yourwebconf}/inc_railo1_conn.inc
Bringing It Together
• Now we have all the pieces, lets configure Apache to use them all.
• If you have not ac)vated Virtual Hos)ng, you need to turn that on by uncommen)ng NameVirtualHost *:80
• This is usually in the main h6pd.conf or / {apachehome}/extra/h6pd---vhosts.conf
Enabling Apache Virtual Host
# Use name-based virtual hosting. # NameVirtualHost *:80
# # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServenName or ServerAlias in any <VirtualHost> block. #
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/'IMW/_'IMWroot" ServerName 127.0.0.1
Directorylndex index.html index.cfm </VirtualHost>
Default Virtual Host
• I usually setup the 127.0.0.1 / localhost in the Vhost file
• Add all other vhosts in the /{webconf}/apache folder for easy accessibility.
• Add this line to the bo6om of the h6pd.conf Include /{yourwebconf}/apache/*.conf
• That is where all the magic happens
Lets Create Some Host Files
• Lets Setup 6 Simple Host Files
– Railo 1 railo1.local.com.conf
– ColdFusion9 cf9.local.com.conf
– ColdFusion10 cf10.local.com.conf
– ColdFusion11 cf11.local.com.conf
Local DNS via Hosts File
• Edit your host file to add the local DNS
– 127.0.0.1 railo1.local.com – 127.0.0.1 cf9.local.com – 127.0.0.1 cf10.local.com – 127.0.0.1 cf11.local.com
• /etc/hosts on Mac / Linux
• /Windows/System32/etc/hosts on Windows
Railo1.local.com Vhost file
• Create file called railo1.local.com.conf <VirtualHost *:80>
ServerAdmin [email protected] DocumentRoot "/www/_wwwcfo/railo1.local.com/" ServerName railo1.local.com
#Include /www/_servers/conf/inc_railo1_conn.inc
</VirtualHost>
cf9.local.com Vhost file
• Create file called cf9.local.com.conf <VirtualHost *:80>
ServerAdmin [email protected] DocumentRoot "/www/_wwwcfo/cf9.local.com/" ServerName cf9.local.com
#Include /www/_servers/conf/inc_cf9_conn.inc
</VirtualHost>
cf10.local.com Vhost file
• Create file called cf10.local.com.conf <VirtualHost *:80>
ServerAdmin [email protected] DocumentRoot "/www/_wwwcfo/cf10.local.com/" ServerName cf10.local.com
#Include /www/_servers/conf/inc_cf10_conn.inc
</VirtualHost>
cf11.local.com Vhost file
• Create file called cf11.local.com.conf <VirtualHost *:80>
ServerAdmin [email protected] DocumentRoot "/www/_wwwcfo/cf11.local.com/" ServerName cf11.local.com
#Include /www/_servers/conf/inc_cf11_conn.inc
</VirtualHost>
Add Folders and Index Files
• Create folders for our sites /{websites}/railo1.local.com
• Create index.html file to know what folder we’re in
• Create index.cfm file to know what folder and engine is running
Railo1’s index.html and index.cfm
• Index.html contains: railo1
• Index.cfm contains: <cfoutput> <h1>#cgi.server_name#</h1> <h2>railo1</h2> <cfdump var="#server#”> </cfoutput>
Lets test our DNS / Apache Hosts
• Sudo apachectl restart – on Mac OSX
• Service h6pd restart – in Linux
• Windows – Restart the service
• Browse to h6p://cf9.local.com/index.html --- see CF9
• Browse to h6p://cf9.local.com/index.cfm --- see source
Lets Startup CF9
• Uncomment the include in the vhost
• Start CF9 & Restart Apache
• Browse to h6p://cf9.local.com/index.cfm --- see Source
• Why? Inc_cf9_conn.inc refers to mod_jun22.so module, which we haven’t loaded, gracefully fails.
Lets Startup CF9 – Add Module
• Edit the h6pd.conf and add the following line above the wildcard directory include so it looks like this
#Include Modules to Load for CF9
Include /www/_servers/conf/inc_cf9_module.inc
#Load Virtual Hosts
Include /www/_servers/conf/apache/*.conf
Lets Startup CF9- Add Module
cf9Jocal.com
CF9
co <lfusoon atruct
Installl<it Nat ve UNIX
appserver JRun4
expriabon {ts '2009-10-3114:41: 53'}
prod<Jctlevel Developer
productnarne ColdFusion Server
productversion 9,0,2,282541
rootCi<i /www/ servers/coldfusion9
supportedlocales Chi!'lese (China),Chinese (Hong Kong),Chinese (Taiwan)D, utch (Belgian),Dutch (Standard),English (Australian),English (Canadian),Engl (Standard),Swedisn,ar,ar_AE,ar BH,ar DZ,ar EG,ar IQ,ar JO,ar KW,ar LB,ar LV,ar MA,ar OM,ar QA,ar SA,ar SD,ar SV,ar TN,ar '
OS
atruct
addit ol'lalinformabol'l Mac OS X arch x86 64
bulidn< mber [empty string]
name Mac OS X
version 10.8.5
Lets Startup CF10 – Add Module
• Edit the h6pd.conf and add the following line above the wildcard directory include, below the CF9 Code, so it looks like this
#Include Modules to Load for CF10
Include /www/_servers/conf/inc_cf10_module.inc
#Load Virtual Hosts
Include /www/_servers/conf/apache/*.conf
Lets Startup CF10
• Uncomment the Include in the vhost
• Start CF10 & Restart Apache
• Browse to h6p://cf10.local.com/index.cfm
• If everything is right, you’ll see the dump on the next slide.
.truct
InstaUKti Native UNIX
appserver J2EE
expirabM {ts '2014-04-07 15:29: 12'}
productlevel Developer
productnarne ColdFusion Server
productvers oo 10 0, 0, 282462
rootdir /www/ servers/co dfuslon10/dus on
supportedloca es Chinese (Ch na),Chinese {Hong Kong) Ch nese (Taiwa.n),Dutdl (Belgian),Outc:h (Standard),Engllsh (Australian) English (canad an)E, ngll! (Standard),Swedlsh ar,,ar_.AE,ar BH,ar DZ,ar EG,ar Q,ar )O,ar KW,ar LB,ar LY,ar MA,ar OM,ar QA ar SA,ar SO ar SY,ar TN
CflO.Iocal.com/index.cfm
cflOJocal.com
CFlO
coldfusoon
OS
Lets Startup CF11
• Wait… didn’t I say earlier that CF11 and CF10 both run on Tomcat, both with the JK Module? --- Yes
• That’s easy though right? – No
• Since the configura)on is different but the module is the same, you can’t just include both.
• Solu)on? Instances
CF10 and CF11 Instances
• Since CF11 is using the newest version of the JK Module, we can use most of the sefngs.
• CF10 needs certain sefngs, as does CF11
• Most importantly, how does the JK Module know which Engine to call?
• Worker.proper)es
Worker.proper)es and Instances
• Worker.proper)es normally just has 1 simple set of instruc)ons.
– List of workers
– Connec)on type
– Host
– Port
– Max Reuse Connec)ons
Worker.proper)es and Instances
• To make CF10 and CF11 work within the same JK Module, we need to update the instance names, so they’re both not “cfusion”
• Lets start with CF10 First, then we’ll do CF11s, then we’ll create a mul)---worker file with both instances.
Update CF10 Instance Name
• Update worker.proper)es /{cf10}/config/wsconfig/1/worker.proper)es
• Update uriworkermap.proper)es /{cf10}/config/wsconfig/1/uriworkermap.proper)es
• Update instances.xml /{cf10}/config/instances.xml
CF10 – old workers.proper)es
worker.list=cfusion
worker.cfusion.type=ajp13
worker.cfusion.host=localhost worker.cfusion.port=8012 worker.cfusion.max_reuse_connec)ons=250
CF10 – new workers.proper)es
worker.list=cfusion10
worker.cfusion10.type=ajp13
worker.cfusion10.host=localhost worker.cfusion10.port=8030 worker.cfusion10.max_reuse_connec)ons=250
CF10 – old uriworkermap.proper)es
/cfformgateway/* = cfusion /CFFormGateway/* = cfusion /flex2gateway/* = cfusion /flex2gateway = cfusion /cffileservlet/* = cfusion /CFFileServlet/* = cfusion /cfform---internal/* = cfusion /flashservices/gateway/* = cfusion /flex---internal/* = cfusion /rest/* = cfusion /*.cfml/* = cfusion /*.mxml = cfusion …. etc
CF10 – new uriworkermap.proper)es
/cfformgateway/* = cfusion10 /CFFormGateway/* = cfusion10 /flex2gateway/* = cfusion10 /flex2gateway = cfusion10 /cffileservlet/* = cfusion10 /CFFileServlet/* = cfusion10 /cfform---internal/* = cfusion10 /flashservices/gateway/* = cfusion10 /flex---internal/* = cfusion10 /rest/* = cfusion10 /*.cfml/* = cfusion10 /*.mxml = cfusion10
CF10 – old instances.xml
<servers> <server>
<name>cfusion</name> <directory>/www/_servers/coldfusion10/cfusion</directory>
</server>
</servers>
CF10 – new instances.xml
<servers> <server>
<name>cfusion10</name> <directory>/www/_servers/coldfusion10/cfusion</directory>
</server>
</servers>
Note: just the instance name, not the path.
CF11 Instance Name Updates
• To make CF10 and CF11 work within the same JK Module, we need to update the instance names, so they’re both not “cfusion”
• Lets start with CF10 First, then we’ll do CF11s, then we’ll create a mul)---worker file with both instances.
CF11 old worker.proper)es
worker.list=cfusion
worker.cfusion.type=ajp13 worker.cfusion.host=localhost
worker.cfusion.port=8014 worker.cfusion.max_reuse_connec)ons=250
CF11 new worker.proper)es
worker.list=cfusion11
worker.cfusion11.type=ajp13 worker.cfusion11.host=localhost
worker.cfusion11.port=8031 worker.cfusion11.max_reuse_connec)ons=250
CF11 old uriworkermap.proper)es
/cfformgateway/* = cfusion /CFFormGateway/* = cfusion
/flex2gateway/* = cfusion /flex2gateway = cfusion
/cffileservlet/* = cfusion
/CFFileServlet/* = cfusion /cfform---internal/* = cfusion
/flashservices/gateway/* = cfusion /flex---internal/* = cfusion
… you get the idea
CF11 new uriworkermap.proper)es
/cfformgateway/* = cfusion11 /CFFormGateway/* = cfusion11
/flex2gateway/* = cfusion11 /flex2gateway = cfusion11
/cffileservlet/* = cfusion11
/CFFileServlet/* = cfusion11 /cfform---internal/* = cfusion11
/flashservices/gateway/* = cfusion11 /flex---internal/* = cfusion11
… you get the idea
CF11 old instances.xml
<servers> <server>
<name>cfusion</name> <directory>/www/_servers/coldfusion11beta/cfusion</
directory>
</server> </servers>
CF11 new instances.xml
<servers> <server>
<name>cfusion11</name> <directory>/www/_servers/coldfusion11beta/cfusion</
directory>
</server> </servers>
New Mul)---Worker File
• Now we have all the files updated, we need to combine the worker file, which allows us to direct calls to the appropriate instance.
• Copy the two files into one, remove the extra worker.list line, and make the remaining one a comma separated list of instances.
CF11 new worker.proper)es
worker.list=cfusion10,cfusion11
worker.cfusion10.type=ajp13
worker.cfusion10.host=localhost worker.cfusion10.port=8030 worker.cfusion10.max_reuse_connec)ons=250 worker.cfusion11.type=ajp13 worker.cfusion11.host=localhost worker.cfusion11.port=8031 worker.cfusion11.max_reuse_connec)ons=250
Upda)ng h6pd to use new Worker File
• Instead of using CF10 or CF11’s module file we created earlier, we’re going to use a hybrid I created. (next slide)
• It points to all of the CF11 module sefngs, except the JKWorkersFile is our new Workerfile
• All the CF10 and CF11 specific stuff has been removed and we’ll add to the connec)on include
New Mul) Instance Worker File
# Load mod_jk module LoadModule jk_module "/{cf11home}/config/wsconfig/1/mod_jk.so"
# Where to find workers.proper)es JkWorkersFile "/{yourwebconf}/workers.proper)es" JkMountFile "/{cf11home}/config/wsconfig/1/uriworkermap.proper)es" JKIPRestric)onFile "/{cf11home}/config/wsconfig/1/iprestric)on.proper)es" # Where to put jk logs JkLogFile "/{cf11home}/config/wsconfig/1/mod_jk.log” # Where to put jk shared memory JkShmFile "/{cf11home}/config/wsconfig/1/jk_shm"
Update CF10’s Connec)on Include
• Since all of the JK Module is loaded is CF11, how can we tell Apache and JK to use CF10’s instance for this site
• We override the JKMountFile. This sets this sites extensions, to an instance name cfusion10
• Add this line to the top of the inc_cf10_conn.inc file JkMountFile "/{cf10home}/config/wsconfig/1/ uriworkermap.proper)es"
Update CF10’s Connec)on Include
• Add this line to the top of the inc_cf10_conn.inc file above the Add Handler line JkMountFile "/{cf10home}/config/wsconfig/1/ uriworkermap.proper)es” # Set the jk log level [debug/error/info] JkLogLevel info # Select the )mestamp log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Update CF11’s Connec)on Include
• Even though all of the JK Module is loaded is CF11, we s)ll need to tell Apache and JK to use CF11’s Mount File, and instance cf11.
• CF11 has a lot of other sefngs, so we’ll add those on a site by site basis by adding it to the top of the inc_cf11_conn.inc file above the add handler
• Some of these sefngs could be shared, but are separated for flexibility.
Update CF11’s Connec)on Include
JkMountFile "/{cf11home}/config/wsconfig/1/ uriworkermap.proper)es”
# custom environment variables
JkEnvVar REDIRECT_URL JkEnvVar REDIRECT_REMOTE_HOST JkEnvVar REDIRECT_PATH JkEnvVar REDIRECT_QUERY_STRING
JkEnvVar REDIRECT_HTTP_ACCEPT JkEnvVar REDIRECT_HTTP_USER_AGENT JkEnvVar REDIRECT_REMOTE_ADDR
Update CF11’s Connec)on Include cont
JkEnvVar REDIRECT_SERVER_NAME JkEnvVar REDIRECT_SERVER_PORT JkEnvVar REDIRECT_SERVER_SOFTWARE
# Set the jk log level [debug/error/info] JkLogLevel info # Select the )mestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Update CF11’s Connec)on Include
• Replace the Apache CF10 Module include
#Include Modules to Load for CF10 Include /www/_servers/conf/inc_cf10_module.inc
• With the new Mul) Purpose Module
#Include Modules to Load for CF10+CF11
Include /www/_servers/conf/inc_cfmul)_module.inc
• Restart Apache & Verify CF10
• Start CF11 and Verify CF11
Verify CFll Started and Works
cfil Jocal.com
CFll
col<!fus.on •truct
lnstaUKit Native UNIX
app5erver Tomcat
expirabo<'l {ts '2014-05-15 16:40: 51'}
producdevel Evaluation
productname ColdFusion Server
productversion 11,0,0,289412
rootdir /www/ servers/ooldruslonllbeta/cfusion
supportedlocales Chinese (China),Chinese (Hong Kong),Chinese (Taiwa'l),Dutch ( Belgian),Dutch (Standard),English (Australian),English (Canadian),Eng (Standard),Swedish,a r,ar ..AE,ar BH,ar OZ,a r EG.ar !Q,ar JO,ar KW,ar LB,ar LV.ar MA.ar OM.ar QA,ar SA,ar SO,ar SV,ar TN,ar_ c.a-japanese,ko,ko KR,It,lt LT,Iv,lv LV,mk,mk_MKm, s,ms MY,mt,mt_MT,nl,nl Bf,nl Nl,no,no O,no 0 NV,pl,pl PL,pt,pt BR t PT
updatelevel 0
OS additionalinformabo'l Mac OS X
arch x86 64
buildn.Jmber [empty string)
name Mac OS X
version 10.8.5
ColdFusion Done – Railo’s Turn
• Since Railo’s AJP method just runs via AJP port, we just need to make sure the port is free.
• We have used 8020 + Version for AJP
– CF10:8030
– CF11:8031
– Railo1:8021
ColdFusion Done – Railo’s Turn
• inc_railo1_conn.inc is set to 8021 already
<Proxy *>
Allow from 127.0.0.1
</Proxy> ProxyPreserveHost On ProxyPassMatch ̂ /(.+\.cf[cm])(/.*)?$ ajp://localhost: 8021/$1$2
• Start Railo and Verify
Verify Raila
Default
Welcome to the Rallo World!
• Getting Started • Community Website • Wlki - Documentation • Rallo Mailing List • Support & Consulting
Railo 4.0
You are now successfully running Railo 4.0. Please check the Railo Server Administrator for available updates and patches.
Important Notes
Thank you for choosing Railo as your CFML engine.If you have installed Railo on a public server, please be sun
If you are new to Railo, please check the Getting Started guide on our page on how to begin. In our Wlki you will
If you want to start running some code in this Railo instance,simply place it in the website's folder at:
/www/_sorvers/railo/tomcat/wcbapps/ROOT/
What’s wrong with Railo?
• That’s not the right confirma)on page, whats wrong with Railo?
• Remember the vhosts having to match? This is what I meant
• Apache sees an index.cfm, Railo serves index.cfm, but from its vhost which is located at / {railo1home}/webapps/ROOT/index.cfm
Solu)on? Tomcat Hosts in Server.xml
• Add / Edit the appropriate hosts in Catalina/ Tomcat’s Server.xml file.
• Tag structure --- Server > Service > Engine – Host
• Hosts have following a6ributes (shown in default file) – Name – Just like main URL in apache vhost – railo1.local.com – appBase – this is similar to your project with web and non web
accessible – I usually leave this as webapps (rela)ve or absolute) – unpackWARs – op)onal – not covered
– autoDeploy – op)onal – not covered
Solu)on? Tomcat Hosts in Server.xml
• Tomcat is a fully fledged Web Server, so Hosts like vhosts can contain many other tags and sefngs, just like Apaches.
• A Value, shown in the default Server.xml is setup for logging
• We’re interested in just the basics – Host – Name A6ribute – Context tag – Child of the Host tag
<Context path="" docBase="/{webs}/railo1.local.com”></Context>
Host Contexts
• The default context is ROOT
• This means cfml is served out of / {railo1home}/webapps/ROOT/ --- note the caps
• Path=“” sets the webroot of the site
• Overriding the ROOT context allows you to use rela)ve or full path loca)ons for docBase.
Host Contexts Cont
• You can set context to include other mappings, just like ColdFusion/Railo CFML mappings.
• <Context path=”/coldbox" docBase=”/ frameworks/coldbox”></Context>
• There are lots of a6ributes for you to research for homework.
Railo1’s Virtual Host
• Add right below localhost host in /{railo1home}/tomcat/conf/server.xml
<Host name=”railo1.local.com" appBase="webapps”>
<Context path="" docBase="/{webs}/railo1.local.com”></ Context>
</Host>
Restart Railoland Verify
railolJocal.com
Railol
1.....
- /www/ wwwdo/railol.local.comI
japanese (japan),spanish (peru),english,ja _JP_JP,spanish (panama),serbian (bosnia and herzegovina),macedonia (cyprus),arabic (qatar),macedonian (macedon a),swedish,german (switzerland),english (united states),finnish (finland and montenegro),lithuanian,romanian,english (new zealand),no_NO_NY,Iithuanian (l thuania),spanish (nicaragua),duto
Wow, that was easy… NOT
• Few things to remember with mul) engine
• Server.xml ports must be unique
– Shutdown port 8006 default – I use 8000 + version
– Webserver port 8500 default – I use 8500 + version
– AJP port 8009 default --- I use 8020 + version
• You open have to resolve clashes, it is much easier with a system.
Do we have )me for Railo Clusters?
• I have some slides on this on my presenta)on site
• Hit me up later if you want to talk more.
Too many hosts
• One of the complaints / confusions with Railo is the mul)ple hosts required in Apache and Tomcat.
• Tomcat does have a Host Manager
• Automa)on? One big file like that is messy
• Is there an easier way?
Include your Hosts
• Like Apache, you can include your hosts, so every)me you edit your hosts, you are not messing with your important server.xml file.
• Server.xml file is xml, so you can use an en)ty include, and include a single xml file.
• This allows you to automate or manually edit an external file, and Tomcat will parse it each restart.
Your Hosts Include File
• Its just simple XML <Host name="railo2.local.com" appBase="webapps">
<Context path="" docBase="/{webs}/railo2.local.com"></Context> </Host>
<Host name="railocluster.local.com" appBase="webapps"> <Context path="" docBase="/{webs}/railocluster.local.com"></Context>
</Host>
Save it as /{yourwebconfs}/inc_railo1_hosts.xml
How to Include the File
• In your server.xml file, right under the opening xml tag, add an en)ty tag
<?xml version='1.0' encoding='uU---8'?>
<!DOCTYPE server---xml [ <!ENTITY vhosts---config SYSTEM "file:///{yourwebconfs}/
inc_railo2_hosts.xml">
]>
• That loads that external xml into a variable (en)ty) called vhosts---config
How to Include the File Cont
• Now we have the variable (en)ty) loaded, scroll down to your hosts, replace the original XML host tags with the following
&vhosts---config;
• Now, when Tomcat starts, it will load the external xml into that variable and it will include that xml wherever that variable is used.
Automate to the Cows Come Home
• Now you have your Apache and Tomcat Conf files in a easy to reach, simple format, you can automate all your site crea)on.
• Remember, Apache and Tomcat need to be restarted if you change their Conf files, before they take effect
• Railo star)ng slow? More Hosts, slower the start Fix here h6p://tonyjunkes.com/blog/fixing---slow---railo--- startup---running---on---tomcat---8
My own CFML Web Manager Tool
• I have been working on a tool to help me manage my dev machines, if you want to try it out, you can get it from github. h6ps://github.com/gpickin/CFMLWebManager
• If we have )me I will show it now, or hit me up later in the conference.
The End
• Thanks everyone for making it this far
• We covered lots of content, we moved pre6y quick… all of the materials will be on my CFO presenta)on Site: h6p://www.gpickin.com/cfo2014/
• Hit me up on twi6er @gpickin
• Read more on my blog: h6p://gpickin.com