Wednesday, January 27, 2010

ColdFusion Manual Configuration & Issues with TCP ports 51011, 51010 and 51800 on IIS and Apache

ColdFusion works by configuring your web server (IIS, or Apache) to execute files with known extensions (.cfm, .cfml, .cfc et al) to run as script. And for doing that ColdFusion comes with a small and important tool called “wsconfig”.

Problem: At times, regardless of operating system and the web server you are using, the ColdFusion installation will fail to configure web-server due to your network settings or firewall/security settings. When running wsconfig tool, you may encounter errors similar to the following:

  • Could not connect to any JRun/ColdFusion servers on host localhost.
    • Possible causes:
      • Server not running
        - Start Macromedia JRun4 or ColdFusion server
      • Server running
        - JNDI listen port in jndi.properties blocked by TCP/IP filtering or firewall on server
        - host restriction in security.properties blocking communication with server

CF-Install-32BitApp

Snapshot above shows one of the common scenario when wsconfig will not configure IIS.

Solution: Here is one fail proof solution to complete the installation of ColdFusion and stop worrying about getting wsconfig to… “run”. Yes, you we will not run “wsconfig”. Instead, we will manually configure web-servers and manually create files that are created by wsconfig.

Let’s first take into account the files that are created or modified by wsconfig:

  1. Create jrunserver.store – The wsconfig tool will create a .store file that the jrun server uses to store port number for connecter to work with your server. Port number for CFMX 6.1 is 51010. Port for CF 7.0 is 51011. And port for CF 8 and CF 9 is 51800. You can check the port number for your machine in jrun.xml file stored in cf_root\runtime\servers\coldfusion\SERVER-INF\jrun.xml – search for “ProxyService” in this file and under the <service> tag you will find <attribute name="port">YOUR PORT NUMBER</attribute>.
  2. For IIS, creates jrun.ini or jrun_iis6.ini – Only when configuring IIS on Windows. For IIS4 and IIS5, a jrun.ini file is created. For later versions, i.e. for IIS6 and II7 jrun_iis6.ini file is created.   
  3. For Apache, modifies httpd.conf – Only when configuring Apache server. The httpd.conf file is part of Apache. Its the web-server configuration file and this file is modified by wsconfig tool so that Apache will load mod_jrun2.so or mod_jrun22.so depending on version of ColdFusion.

wsconfig-folder

Let’s Just Do It Manually

  • Open jrun.xml file found at cf_root\runtime\servers\coldfusion\SERVER-INF\. Edit the file, find “ProxyService” and change value of deactivated to true. Like shown in the snapshot below. 
    Jrun-ProxyService-Deactivated-True 
  • After you have edited the above XML file, you must restart the ColdFusion Application server.
  • Create wsconfig.properties file – this file is created by wsconfig tool to store the list of servers it has configured. Take a look at the following snap-shot – the wsconfig tool will store two records in wsconfig.properties file when you have both IIS and Apache configured. So, if you have just one server configured then only one record is saved in the file and the same is shown in the tool. 
    WsConfig-Tool
    WsConfig.Properties
    • Create wsconfig.properties file at cf_root/runtime/lib/wsconfig
    • Edit the file to contain following information depending on your server:
      • For IIS:
        • For ColdFusion 7+
          1 =IIS,1,false,""
          1 .srv=localhost,"coldfusion"
          1.cfmx=true,C:/inetpub/wwwroot
        • For ColdFusion MX 6.1, instead of the above line, enter:
          1 =IIS,1,false,""
          1 .srv=localhost,"default"
          1.cfmx=true,C:/inetpub/wwwroot
      • For Apache:
        • On Windows:
          1=Apache,C:/Apache Group/Apache2/conf,"","",""
          1 .srv=localhost,"coldfusion"
          1.cfmx=true,<null>
        • On Unix:
          1=Apache,/opt/apache/2.0.47/conf,"","",""
          1 .srv=localhost,"coldfusion"
          1.cfmx=true,<null>
  • Extract connector files (DLL or SO files) from wsconfig.jar: The wsconfig tool will extract the DLL files from wsconfig.jar file. Which files are extracted depends on the server you are running. When you are running IIS4 or IIS5 or IIS6 or IIS7 the wsconfig tool will extract *.dll files specific for your version. When running Apache, specific *.so file for your version is extracted.  Now, lets look into specific details for each server and see what files are extracted for a specific web server:
  • IIS 6 and IIS 7 configuraton: wsconfig-folder-1

    1. Extract jrunwin32.dll and jrun_iis6.dll from cf_root\runtime\lib\wsconfig.jar and copy them to cf_root\runtime\lib\wsconfig\.
    2. Extract jrun_iis6_wildcard.dll from cf_root\runtime\lib\wsconfig.jar and copy it to cf_root\runtime\lib\wsconfig\1.
    3. Create a jrun_iis6_wildcard.ini file in cf_root\runtime\lib\wsconfig\1. It should contain the following information: 

      verbose=false
      serverstore=cf_root/runtime/lib/wsconfig/1/jrunserver.store (use absolute path. see note below)
      bootstrap=127.0.0.1:51800 (port number differs by version of ColdFusion server. see note below)
      apialloc=false
      ssl=false
      #errorurl=<optionally redirect to this URL on errors>

      Notes:

      • serverstore above should point to actual JRun 4 installation
      • bootstrap port number for ColdFusion 9 is 51800, for ColdFusion 7 and 8 port number is 51011. And, for ColdFusion 6 the port number is 51010.
    4. Create the jrunserver.store file in cf_root\runtime\lib\wsconfig\1. Edit as follows:

      proxyservers=127.0.0.1:51800 (127.0.0.1:51010 for MX 6.1; 127.0.0.1:51011 for MX 7)
  • Specific for IIS 6:
    1. Using the IIS Management Console, add a new Web Service Extension named Macromedia Server Extensions. Set the status to Allowed. Set Required Files to
      cf_root\runtime/lib\wsconfig\1\jrun_iis6_wildcard.dll and cf_root\runtime\lib\wsconfig\jrun_iis6.dll.
    2. Right-click on the website you are connecting and select the properties. Select the Home Directory tab and click on the Configuration button. Add extension mappings in the Application extensions for .cfc, .cfm, .cfml, .cfr, .cfswf,.jsp and .jws. Point all of them to cf_root\runtime\lib\wsconfig\jrun_iis6.dll.
    3. In the Wildcard application maps at the lower half of the same window, insert the following:
      cf_root\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll.
  • Specific or IIS 7:
    1. Under the IIS Management Console, click on your computer name, click on “ISAPI and CGI Restrictions” and add two entries: one for cf_root\runtime/lib\wsconfig\1\jrun_iis6_wildcard.dll and the other for cf_root\runtime\lib\wsconfig\jrun_iis6.dll. Set both to allowed.
       ISAPI and CGI Restrictions
    2. Click on your computer name and click on “Handler Mappings” and add one “Wildcard Script Map”:
      Add-Wildcard-Script-Map
    3. After adding wildcard script map, add script handlers for *.cfm files:
      Add Script Map 
    4. Add other file extensions that are supported by your version of ColdFusion. For ColdFusion 9, you will add the following script handler mappings (*.jsp, *.jws, *.cfml, *.cfc, *.cfr, *.cfswf, *.hbmxml):
       Handler-Mappings

  • IIS 4 or IIS 5 configuration:

    1. Extract jrunwin32.dll from cf_root\runtime\lib\wsconfig.jar and copy it to cf_root\runtime\lib\wsconfig\.
    2. Extract jrun.dll from cf_root\runtime\lib\wsconfig.jar and copy it to cf_root\runtime\lib\wsconfig\1.
    3. Create a jrun.ini file in cf_root\runtime\lib\wsconfig\1. It should contain the following information:

      verbose=false
      scriptpath=/JRunScripts/jrun.dll (must be a valid URL. see note below)
      serverstore={cf-root}/runtime/lib/wsconfig/1/jrunserver.store (use absolute path. see note below)
      bootstrap=127.0.0.1:51800 (port number varies by version of CF. see note below)
      apialloc=false
      ssl=false
      ignoresuffixmap=false
      #errorurl=<optionally redirect to this URL on errors>

      Notes:

      • scriptpath above points to /JRunScripts/jrun.dll and it must be a valid URL. Using the IIS Management Console, add a virtual directory named JRunScripts to the website. The Local Path property of the folder should point to cf_root\runtime\lib\wsconfig\1 and Execute Permissions must be set to "Scripts and Executables"
      • serverstore above should point to actual JRun 4 installation
      • bootstrap port number for ColdFusion 9 is 51800, for ColdFusion 7 and 8 port number is 51011. And, for ColdFusion MX 6.1 the port number is 51010.
    4. Add the JRunConnector Filter to the ISAPI Filter properties of the website:
    1. Right-click on the website.
    2. Select the ISAPI Filters tab.
    3. Click the Add button.
    4. In the Filter Name text box, enter "JRun Connector Filter".
    5. In the Executable text box, browse to or enter "cf_root\runtime\lib\wsconfig\1\jrun.dll".
    6. Select the Home Directory tab and click on the Configuration button. Add extension mappings in the Application extensions for .cfc, .cfm, .cfml, .cfr, .cfswf, jsp and .jws. Point all of them to cf_root\runtime\lib\wsconfig\1\jrun.dll.
    7. Restart the World Wide Web Publishing service from the Windows Control Panel and check the ISAPI Filter property for the website. The JRun Connector Filter should show a high priority with a green arrow pointing upwards.
  • For Apache web server:

    wsconfig-folder-2
    1. Extract the .SO file file for your Apache server version from wsconfig.jar file. In the screenshot above you will see that mod_jrun22.so has been extracted. mod_jrun20.so supports Apache 2.x web servers. To connect to Apache 1.3.x, use mod_jrun.so.
    2. Create jrunserver.store file under cf_root\runtime\lib\wsconfig\1 directory with the following files:
      jrunserver.store - Create a file called jrunserver.store and enter the following information:
      • For ColdFusion MX 6.1:
        proxyservers=127.0.0.1:51010
      • For ColdFusion MX 7:
        proxyservers=127.0.0.1:51011
      • For ColdFusion 8 and ColdFusion 9
        proxyservers=127.0.0.1:51800
    3. Edit the Apache configuration file (located in apache_install_directory/conf/httpd.conf) and add the following section at the end of the file:
      # JRun Settings
      LoadModule jrun_module "cf_root/runtime/lib/wsconfig/2/mod_jrun22.so"
      <IfModule mod_jrun22.c>
          JRunConfig Verbose false
          JRunConfig Apialloc false
          JRunConfig Ignoresuffixmap false
          JRunConfig Serverstore "cf_root/runtime/lib/wsconfig/2/jrunserver.store"
          JRunConfig Bootstrap 127.0.0.1:51800
          #JRunConfig Errorurl url <optionally redirect to this URL on errors>
          #JRunConfig ProxyRetryInterval 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>
          #JRunConfig 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
      </IfModule>

      Notes:

      • LoadModule jrun_module must point to actual location of .so file using absolute path.
      • JRunConfig Serverstore must point to actual location of .store file created in step #2.
      • JRunConfig Bootstrap must use the correct port number. For ColdFusion 9 use 51800. For MX 7 use 51011 and for MX 6.1 use 51010.
    4. Restart the Apache web server.

 

If you are on IIS, you might have to restart the IIS web server, but in most cases you won’t have to.

Now, you’re finished configuring your ColdFusion server with your web server without running wsconfig tool. This will help those who find that wsconfig is failing to configure their web servers. Phew!

☛ Quick Links

♥ Recommended For You