Running Railo from any directory in Windows 7

Running Railo from any directory in Windows 7

Yesterday I posted a question on the Railo mailing list to find out if anyone had ever made a shell script / batch file that would spawn Railo contexts based on your current directory.

For instance:

$ cd /path/to/sites_folder/ 
$ mkdir my_new_site 
$ cd my_new_site 
$ railo new

Mark Drew responded almost immediately with some suggestions but nothing bullet proof at first.

Then, a few hours later… He posted a full solution and it works brilliantly. His instructions applied to Mac OS X but they almost directly translate to Windows 7, but if you don’t feel like translating… here is it!

Instructions

Download and Extract Railo Express

To get started, download Railo Express.

I recommend downloading the version with JRE for the quickest and smoothest setup. Also, keep in mind which version you’re downloading.

The current download page offers 4.0.0.xxx BETA first, and if you scroll down you will see Railo 3.3.4.xxx versions. In the Adobe world, this translates to (fairly smoothly): Railo 3.3.4 ~= CF9, and Railo 4.0.0 ~= CF10.

Extract the contents of the zip file to C:\Railo to keep things as clean and simple as possible.

If you desire to be able to spawn multiple versions of Railo based on a given folder, I suggest you name it Railo3 and Railo4 respectively and ensure all of your paths in all of the steps matches this folder name.

Setup the .bat script

Now, navigate to the C:\Railo directory and copy/paste the file start.bat which should give you a Copy of start.bat file.

Rename that file to railo_init.bat.

Right click on railo_init.bat and click Edit, or Open With > Your Favorite Editor.

The contents of this file should look like this, give or take your path names based on your preference.

set currpath=%CD%
cd %~dp0
java -DSTOP.PORT=8887 -DSTOP.KEY=railo -Xms256M  -Xmx512M -jar l
ib/start.jar -Drespath=%CURRPATH%

Save (CTRL+S) the railo_init.bat and you may close it now.

Modify the railo.xml context

Open up C:\Railo\contexts\railo.xml with your favorite text / markup editor. Notice the commented out line and the new version of that line directly below it.

#!xml
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/</Set>
    <!--
    <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webroot/</Set>
    -->
    <Set name="resourceBase"><SystemProperty name="respath" default="."/>/</Set>
    <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
</Configure>

Now save railo.xml and close it.

Update your PATH System Variable

Click Start Orb >

start menu

Right-click Computer > Select Properties from the menu.

Context Menu

Now click Advanced system settings.

advanced system settings

On the Advanced tab, click Environment Variables button.

environment variables button

Under System variables, scroll down to Path, select it and click Edit

Path variables

Now, move your cursor to the end of the Variable value: field, and make yours look like below. Type ;C:\Railo;

editing path variable

Now, click Ok a million times until you’re closed out of all of these windows.

Initialize your first web app directory.

Open up a fresh Windows Console by clicking Start Orb and typing cmd. (NOTE: You may want to right click on cmd and click Run As Administrator if for some reason you run into permissions issues)

Start by typing cd C:\path_to_your_sites_root\ replacing the obvious with your actual sites root folder where you house your web projects.

cd C:\path_to_your_sites\ mkdir my_new_site cd my_new_site railo_init

This should now start copying required files over to your my_new_site directory and start a web server listening on http://localhost:8888/. If you browse to that in your browser, you should be presented with your my_new_site empty directory.

You may now proceed to add your favorite CFML framework or add an index.cfm to get started.

For all future apps, all you have to do is open up a console, type those commands, and it will setup a new Railo context running in that folder. Awesome!

Issues

If you have any problems or issues with this solution, please feel free to let me know, or post them to the Railo Google Groups

Future enhancements

I’m currently working on a CFWheels Framework tool written in Node.js that will enhance this process by generating a CFWheels application with my new Asset Pipeline plugin built in.

How to do this in Mac OS X

Here is Mark Drew’s post on his blog with detailed instructions on the Mac OS X implementation: Running Railo from any directory on Mac OS X

Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax