Team of Expert ColdFusion Programmers Developing Rich ColdFusion Application Development Services
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
-
Upload
gavin-pickin -
Category
Software
-
view
34 -
download
0
Transcript of Setting up your Multi Engine Environment - Apache Railo and 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
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.
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
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
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
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 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.
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
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
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>
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.