The new ColdFusion 2016 version is different from its predecessors. The configuration files are laid out slightly differently. I wanted to install the newest version of ColdFusion but I could not configure the instances and virtual hosts of my existing projects like usual. After some digging around, I found the way. This post is to show how to setup multiple ColdFusion server instances and map them to their own virtual hosts, also known as multi-homing.
Long Story Short
I have found it is the same procedure as in Coldfusions 10 and 11, with the difference that there is no need to edit the server.xml file in every new instance's /runtime/conf directory and you must uncomment the last line in the instance's uriworkermap.properties file. Still, I will write the entire procedure for you if you're new to this or you're just a little rusty.
Requirements
- ColdFusion 2016 installed
- Apache web server installed
Note: I am working on an OS X machine but the procedure shouldn't be too different from a Windows or Linux machine.
Step 1
Creating the new instance
Go to the ColdFusion Administrator and create a new instance at the Instance Manager section of the Administrator. For this example, I will name the new instance test.
click to zoom |
Once the instance has been created, take notice of the Remote Port number assigned to the newly created instance and try to remember it, we will use it in the next step. Do not start the new instance yet.
click to zoom |
Step 2
Updating the workers.properties file
Inside your ColdFusion2016 folder, wherever it is you have ColdFusion installed, open the config/wsconfig/1/workers.properties file. The file contents should look like this:
worker.list=cfusion
worker.cfusion.type=ajp13
worker.cfusion.host=localhost
worker.cfusion.port=8016
worker.cfusion.connection_pool_timeout=60
You will add the name of your instance to the list in the first line (separated by a comma), duplicate the last block of 4 lines, then in the duplicated lines you will change the name cfusion for the name of the new instance you created and the port number to the same number of the Remote Port from the previous step and save the changes. In the end, it should look like this:
worker.list=cfusion,test
worker.cfusion.type=ajp13
worker.cfusion.host=localhost
worker.cfusion.port=8016
worker.cfusion.connection_pool_timeout=60
worker.test.type=ajp13
worker.test.host=localhost
worker.test.port=8012
worker.test.connection_pool_timeout=60
Step 3
Creating a .properties file for the new instance
In the same directory as the workers.properties file we edited in the previous step you should find a file called uriworkermap.properties. Duplicate that file and rename the new file, adding the name of the new instance to identify it. For example, I named the file uriworkermap_test.properties. Then you will open this new file and the contents should look like this:
/cfformgateway/* = cfusion
/CFFormGateway/* = cfusion
/flex2gateway/* = cfusion
/flex2gateway = cfusion
/cffileservlet/* = cfusion
/CFFileServlet/* = cfusion
/cfform-internal/* = cfusion
/flashservices/gateway/* = cfusion
/flex-internal/* = cfusion
/rest/* = cfusion
/api/* = cfusion
/*.mxml = cfusion
/*.as = cfusion
/*.cfm = cfusion
/*.CFM = cfusion
/*.Cfm = cfusion
/*.cfm/* = cfusion
/*.CFM/* = cfusion
/*.Cfm/* = cfusion
/*.swc = cfusion
/*.cfml = cfusion
/*.CFML = cfusion
/*.Cfml = cfusion
/*.cfml/* = cfusion
/*.CFML/* = cfusion
/*.Cfml/* = cfusion
/*.cfc = cfusion
/*.CFC = cfusion
/*.Cfc = cfusion
/*.cfc/* = cfusion
/*.CFC/* = cfusion
/*.Cfc/* = cfusion
/*.cfr = cfusion
/*.CFR = cfusion
/*.Cfr = cfusion
/*.cfswf = cfusion
/*.CFSWF = cfusion
/*.Cfswf = cfusion
/*.sws = cfusion
/*.jsp = cfusion
/*.hbmxml = cfusion
!/CFIDE/* = cfusion
Like in the previous step, you will change the name cfusion for the name of the new instance and make sure to remove the exclamation mark (!) at the last line and save the changes.
/cfformgateway/* = test
/CFFormGateway/* = test
/flex2gateway/* = test
/flex2gateway = test
/cffileservlet/* = test
/CFFileServlet/* = test
/cfform-internal/* = test
/flashservices/gateway/* = test
/flex-internal/* = test
/rest/* = test
/api/* = test
/*.mxml = test
/*.as = test
/*.cfm = test
/*.CFM = test
/*.Cfm = test
/*.cfm/* = test
/*.CFM/* = test
/*.Cfm/* = test
/*.swc = test
/*.cfml = test
/*.CFML = test
/*.Cfml = test
/*.cfml/* = test
/*.CFML/* = test
/*.Cfml/* = test
/*.cfc = test
/*.CFC = test
/*.Cfc = test
/*.cfc/* = test
/*.CFC/* = test
/*.Cfc/* = test
/*.cfr = test
/*.CFR = test
/*.Cfr = test
/*.cfswf = test
/*.CFSWF = test
/*.Cfswf = test
/*.sws = test
/*.jsp = test
/*.hbmxml = test
/CFIDE/* = test
(Note:It is this last line that creates a virtual directory to this new instance's ColdFusion Administrator. If you do not uncomment this line by removing the exclamation mark, then whenever you try to access the ColdFusion Administrator for this instance, it will take you to the main instance's Administrator instead [cfusion])
Step 4
Creating the virtual host
Now you must create the virtual host that will exclusively use the newly created ColdFusion instance. Go to where the virtual hosts are defined in your Apache configuration (It may be in Apache's httpd.conf file or the httpd-vhosts.conf file, check your Apache web server's documentation.) and add a new virtual host. It would be the same as any other virtual host you may have defined before, with one key difference: the inclusion of the JkMountFile
parameter, which points to the .properties file we created in the previous step. It should look something like this:
<VirtualHost *:80>
DocumentRoot "/Users/rulloa/Sites/test"
ServerName test.local
JkMountFile "/Applications/ColdFusion2016/config/wsconfig/1/uriworkermap_test.properties"
<Directory "/Users/rulloa/Sites/test">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Step 5
Adding the registry to the hosts file
Make sure to add the virtual host's ServerName
from the previous step to your computer's hosts file (the location of this file may vary depending on your operating system, check your operating system's documentation.)
127.0.0.1 test.local
Step 6
Firing everything up
Start the new Coldfusion instance and restart Apache so the changes take place. You should be able to see http://test.local from your browser and able to access the instance's ColdFusion Administrator fount at http://test.local/CFIDE/administrator.