Steven Brown

Integrating Jaxer with WampServer

by on Dec.27, 2008, under Jaxer

WampServer makes it easy to get started with a standard PHP setup, fortunately adding Jaxer to your existing WampServer setup is not too difficult.

Currently this guide is designed to work with version 1.0.1.4310. For the purpose of this guide I will assume the installation directory is C:\wamp, be sure to alter the paths in the instructions to match your installation if it is different to this.

To start with you’ll need to download Jaxer and copy the required files into your WampServer folder:

  1. Download Jaxer from the Aptana website at http://www.aptana.com/jaxer/download. Simply grab the “Jaxer Package with self-contained Apache (.zip)” for Windows.
  2. Create the following folders:
    • C:\wamp\bin\jaxer
    • C:\wamp\bin\jaxer\jaxer1.0.1.4310
    • C:\wamp\bin\jaxer\local_jaxer
  3. Inside the ZIP file is a folder called “Aptana Jaxer” and within that is a folder called “jaxer”, copy everything within this “jaxer” folder to C:\wamp\bin\jaxer\jaxer1.0.1.4310.
  4. Copy everything from C:\wamp\bin\jaxer\jaxer1.0.1.4310\default_local_jaxer to C:\wamp\bin\jaxer\local_jaxer

Now you need to modify your Apache configuration. How you do this will really depend on your needs, but here is a general guide. In your C:\wamp\bin\apache\apache2.2.conf\httpd.conf file, add the following, I put it just before the <IfModule dir_module> line:

<ifModule jaxer_module>
    DefaultInitEnv "SystemRoot" "c:/windows"
 
    ########################################################################################
    #  Jaxer Manager Connection settings ( see http://www.aptana.com/jaxer/connectionpool)
    ########################################################################################
    #  WaitConnectionTimeOutSec 5
    #  MaxConnectionPoolSize 1
    ########################################################################################
 
    # Configures the only worker in the form of
    # JaxerWorker <jaxerServerHost> <jaxerServerPort>
    JaxerWorker 127.0.0.1 4327
 
    ########################################################################################
    # Limit the in-memory postdata size.
    ########################################################################################
 
    # Post data larger than this will be put into diskfile.  The default is 4096 bytes.  To
    # turn off this limit, set it to 0.
    # PostDataMemoryLimit <bytes>
    PostDataMemoryLimit 4096
 
    ########################################################################################
    # Special Jaxer paths
    ########################################################################################
 
    # Route all requests that start with jaxer-callback in their path to Jaxer as callbacks
    <locationMatch "^/jaxer-callback\b">
        SetHandler JAXER
        Order Deny,Allow
        Allow from all
    </locationMatch>
 
    # Route all requests with jaxer-rpc in their path to Jaxer as Remote Procedure Calls
    <locationMatch "/jaxer-rpc\b">
        SetHandler JAXER
        Order Deny,Allow
        Allow from all
    </locationMatch>
 
    # Route all requests with jaxer-service in their path to Jaxer as service calls
    <locationMatch "/jaxer-service\b">
        SetHandler JAXER
        Order Deny,Allow
        Allow from all
    </locationMatch>
 
    # Place any files that are not to be filtered through Jaxer at all
    # in a folder structure that has /jaxer-bypass/ somewhere in the hierarchy above them.
    <locationMatch "/jaxer-bypass/">
        # prevents processing by Jaxer before it's served back to Jaxer
        JaxerPassThrough on
        Order Deny,Allow
        Allow from all
    </locationMatch>
 
    # Place any files that are to be served only to Jaxer (usually to be included)
    # in a folder structure that has /jaxer-include/ somewhere in the hierarchy above them.
    <locationMatch "/jaxer-include/">
        # prevents processing by Jaxer before it's served back to Jaxer
        JaxerPassThrough on
        Order Deny,Allow
        # Jaxer will fetch these files directly from the file system, not via Apache
        Deny from all
    </locationMatch>
 
    ########################################################################################
    # Configure default content serving
    ########################################################################################
 
    # Configure the client framework file availablitly
    <directory "c:/wamp/bin/jaxer/jaxer1.0.1.4310/framework">
        Deny from all
        <files clientFramework*.js>
            Allow from all
        </files>
    </directory>
    Alias /jaxer/framework/clientFramework_compressed.js "c:/wamp/bin/jaxer/jaxer1.0.1.4310/framework/clientFramework_compressed.js"
    Alias /jaxer/framework/clientFramework.js "c:/wamp/bin/jaxer/jaxer1.0.1.4310/framework/clientFramework.js"
 
    <directory "c:/wamp/bin/jaxer/jaxer1.0.1.4310/aptana">
        JaxerFilter .html .xhtml .htm
        JaxerFilterContentType text/html application/xhtml+xml
        Order Deny,Allow
        Allow from all
    </directory>
    Alias /aptana "c:/wamp/bin/jaxer/jaxer1.0.1.4310/aptana"
 
</ifModule>

Keep in mind this will attach the settings to every VirtualHost configuration you have, you might want to move some of these settings to only the VirtualHosts where you want Jaxer parsing.

You will also need to add the following lines to enable Jaxer parsing of certain file extensions and content types, I have a generic <Directory “c:/allsites/”> where I place these, however you may want to make them VirtualHost specific:

    #
    # Add Jaxer parsing
    #
    JaxerFilter .html .xhtml .htm
    JaxerFilterContentType text/html application/xhtml+xml

So now your Apache is properly configured, but you need to set up the Jaxer Manager to process Jaxer code. There are two ways to do this, one is to set up the Jaxer Manager as a service, and the other is to manually run it each time you need Jaxer to process requests. While manually running Jaxer Manager can be painful, it tends to be easier to recover from terminal problems than the service installation. To start Jaxer Manager manually, make some small changes to C:\wamp\bin\jaxer\jaxer1.0.1.4310\StartJaxer.bat:

if not defined JAXER_LOG_OUTPUT set JAXER_LOG_OUTPUT=%~dp0\..\..\..\logs\jaxer.log
if not defined JAXER_TEMP set JAXER_TEMP=%~dp0\..\..\..\tmp
if not defined JAXER_CFG set JAXER_CFG=%~dp0\..\local_jaxer\conf\JaxerManager.cfg

These path settings at the top of the file will use the correct WampServer locations rather than the Jaxer defaults.

If you want complete integration with WampServer you should install Jaxer Manager as a service, the easiest way to do this is to create C:\wamp\bin\jaxer\jaxer1.0.1.4310\InstallJaxer.bat with the following contents:

@echo off
 
if not defined JAXER_WEB_PORT set JAXER_WEB_PORT=4327
if not defined JAXER_COMMAND_PORT set JAXER_COMMAND_PORT=4328
if not defined JAXER_LOG_OUTPUT set JAXER_LOG_OUTPUT=%~dp0\..\..\..\logs\jaxer.log
if not defined JAXER_TEMP set JAXER_TEMP=%~dp0\..\..\..\tmp
if not defined JAXER_CFG set JAXER_CFG=%~dp0\..\local_jaxer\conf\JaxerManager.cfg
 
start /b /wait Jaxer -reg -tempdir "%JAXER_TEMP%" &gt; nul 2&gt;&amp;1
start /b JaxerManager -i --configfile="%JAXER_CFG%" --webport=%JAXER_WEB_PORT% --commandport=%JAXER_COMMAND_PORT% --cfg:tempdir="%JAXER_TEMP%" --log:output="%JAXER_LOG_OUTPUT%" 1&gt; nul
start /b JaxerManager -s

This will install and start the Jaxer Manager service and it will use the correct WampServer locations.

At this point you should have a complete and working Jaxer integration with your existing WampServer installation, however things would not be complete unless you could control Jaxer using the WampServer system tray utility.

First, add the following to C:\wamp\wampmanager.conf:

[jaxer]
jaxerVersion = "1.0.1.4310"
jaxerLastKnown = 1.0.1.4310
jaxerExeDir = .
jaxerExeFile = JaxerManager.exe
jaxerServiceInstallParams = -i
jaxerServiceRemoveParams = -u

Then inside C:\wamp\wampmanager.tpl adding the following under the [Services] heading:

Name: "Jaxer Manager"

Then under [StartupAction] before ;WAMPSTARTUPACTIONEND:

Action: service; Service: "Jaxer Manager"; ServiceAction: startresume; Flags: ignoreerrors

Then under [Menu.Left] after:

Type: submenu; Caption: "PHP"; SubMenu: phpMenu; Glyph: 3

Add:

Type: submenu; Caption: "Jaxer"; SubMenu: jaxerMenu; Glyph: 3

Then after:

[phpVersion]
;WAMPPHPVERSIONSTART
;WAMPPHPVERSIONEND

Add:

[jaxerMenu]
;WAMPJAXERMENUSTART
Type: submenu; Caption: "Service"; SubMenu: jaxerService; Glyph: 3
Type: item; Caption: "${w_jaxerLog}"; Glyph: 6; Action: run; FileName: "notepad.exe"; parameters:"${c_installDir}/${logDir}jaxer.log"
;WAMPJAXERMENUEND

Then after:

[apacheService]
;WAMPAPACHESERVICESTART
Type: separator; Caption: "${w_apache}"
Type: item; Caption: "${w_startResume}"; Action: service; Service: wampapache; ServiceAction: startresume; Glyph: 9
;Type: item; Caption: "${w_pauseService}"; Action: service; Service: wampapache; ServiceAction: pause; Glyph: 10
Type: item; Caption: "${w_stopService}"; Action: service; Service: wampapache; ServiceAction: stop; Glyph: 11
Type: item; Caption: "${w_restartService}"; Action: service; Service: wampapache; ServiceAction: restart; Glyph: 12
Type: separator
Type: item; Caption: "${w_testPort80}"; Action: run; FileName: "${c_phpExe}";Parameters: "-c . testPort.php";WorkingDir: "$c_installDir/scripts"; Flags: waituntilterminated; Glyph: 9
Type: item; Caption: "${w_installService}";  Action: multi; Actions: ApacheServiceInstall; Glyph: 8
Type: item; Caption: "${w_removeService}"; Action: multi; Actions: ApacheServiceRemove; Glyph: 7
;WAMPAPACHESERVICEEND

Add:

[jaxerService]
;WAMPJAXERSERVICESTART
Type: separator; Caption: "${w_jaxer}"
Type: item; Caption: "${w_startResume}"; Action: service; Service: "Jaxer Manager"; ServiceAction: startresume; Glyph: 9
Type: item; Caption: "${w_stopService}"; Action: service; Service: "Jaxer Manager"; ServiceAction: stop; Glyph: 11
Type: item; Caption: "${w_restartService}"; Action: service; Service: "Jaxer Manager"; ServiceAction: restart; Glyph: 12
Type: separator
Type: item; Caption: "${w_installService}";  Action: multi; Actions: JaxerServiceInstall; Glyph: 8
Type: item; Caption: "${w_removeService}"; Action: multi; Actions: JaxerServiceRemove; Glyph: 7
;WAMPJAXERSERVICEEND

Under [StartAll] before ;WAMPSTARTALLEND add:

Action: service; Service: "Jaxer Manager"; ServiceAction: startresume; Flags: ignoreerrors

Under [StopAll] before ;WAMPSTOPALLEND add:

Action: service; Service: "Jaxer Manager"; ServiceAction: stop; Flags: ignoreerrors

Under [RestartAll] after:

Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated

Add:

Action: service; Service: "Jaxer Manager"; ServiceAction: stop; Flags: ignoreerrors waituntilterminated

After:

Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated

Add:

Action: service; Service: "Jaxer Manager"; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated

And finally under [myexit] after:

Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors

Add:

Action: service; Service: "Jaxer Manager"; ServiceAction: stop; Flags: ignoreerrors

Now if your start the WampServer system tray utility you should see a new Jaxer menu. The Jaxer Manager service will be started when the utility is started, and stopped when the utility is stopped. As with the Apache and MySQL services, the Jaxer Manager service will automatically start when Windows starts, you can modify these settings in the Windows service manager.


1 Comment for this entry

  • Dan

    I was very curious to give this a go, although i’m running AppServ, so i don’t know how much the configuration varies.

    Essentially the Apache config would be the same albeit different paths within the directives.

    I discovered a number of errors in the Jaxer log, which i corrected by changing the port number specified in your tutorial.

    In the end i could seem to get it working, so instead of creating a new directive, i used the existing one for my standard www root folder.

    It wouldn’t error at that point, so i created a basic Jaxer script and added it to my www folder and viewed it in my browser. It appeared and didn’t error on the screen, but when i cheked the Jaxer log it had the following error.

    16:36:53 07/28/2010 [ 11664] [ERROR] [JS Framework] [framework.onHandleCallback] Could not retrieve version number from http://update.aptana.com/update/jaxer/win32/version.txt
    Error ….

    Any ideas?

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!