Call Overmortal now at 1 (540) 491-0374 or for more information!

Installing Aptana Jaxer with Apache VirtualHosts

Aptana's Jaxer is a server side JavaScript framework that allows you to code entire applications (frontend and backend) in HTML, CSS and JavaScript, while using AJAX to postback data from JavaScript events. Sound interesting? We thought so too so we went about installing Jaxer on our server. We realized right away that the default installation wasn't going to work for us, as we wanted to integrate things directly with our current Apache configuration. After some searching and trial and error, we managed to get the setup to work the way we wanted it.

So here you go:

We use Linux servers, so after grabbing the downloads from the Jaxer download site, you can then work your way through the Jaxer Quick Start Guide.

This guide will get you through the basic installation with a few hiccups. The first hiccup is Linux dependencies. The Jaxer install requires the firefox-devel packages in order to work. The Jaxer documentation mentions this. The Jaxer documentation also mentions the possibility of an error about a missing dependency based on a filename difference for libexpat. You'll have to run the following command if this is the case:

ln -s /lib64/libexpat.so.0 /lib64/libexpat.so.1

The Jaxer documentation does not inform you of other missing dependencies. One of the issues we ran into dealt with missing "X" libraries because we were installing Jaxer on a server specifically built for the command line.

Assuming you've installed Jaxer in the default location, run the following command to determine what libraries you're missing:

ldd /opt/AptanaJaxer/jaxer/jaxer  

This will tell you what dependencies you still need to install. You may already have some of these on your system, but just not in your library export path. Use the Linux "locate" command to see if these are present. If not, search the Internet to find what packages they are in and install them via "yum" or "rpm." For those that are on your system, but not in your library path, edit the /etc/ld.so.conf file to include these directories.

Now that your libraries are up-to-date, you should be able to run Jaxer just fine with the included Apache instance. But we wanted to integrate it with our current instance, so we had a little more work to do. For this, find the linux configuration file in /opt/Aptana_Jaxer/jaxer/confs and include this in your current Apache configuration using the Apache "Include" directive.

Now you should be all set with the exception of getting Jaxer to work with VirtualHosts. This solution can be found on N.L. Smith's web site, but we've included it here also:

<VirtualHost *:80>
        ServerAdmin webmaster@example.com
        ServerName example.com
        ServerAlias www.example.com *.example.com
        DocumentRoot /var/www/www.example.com
        ServerSignature Off
        LogLevel warn
        CustomLog logs/www.example.com-access.log combined
        FileETag none
        <Location /static>
                SetOutputFilter DEFLATE
                SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
                ExpiresActive On
                ExpiresDefault "access plus 5 years"
        </Location>
        LoadModule jaxer_module "/opt/AptanaJaxer/jaxer/connectors/mod_jaxer.so"
        <IfModule jaxer_module>
                JaxerWorker 127.0.0.1 4327
                <Location "/jaxer-server">
                      SetHandler JAXER
                      Order Deny,Allow
                      Allow from all
                </Location>
                <LocationMatch "^/jaxer-callback\b">
                        SetHandler JAXER
                        Order Deny,Allow
                        Allow from all
                </LocationMatch>
                <LocationMatch "/jaxer-rpc\b">
                        SetHandler JAXER
                        Order Deny,Allow
                        Allow from all
                </LocationMatch>
                <LocationMatch "/jaxer-service\b">
                        SetHandler JAXER
                        Order Deny,Allow
                        Allow from all
                </LocationMatch>
                <LocationMatch "/jaxer-bypass/">
                        JaxerPassThrough on
                        Order Deny,Allow
                        Allow from all
                </LocationMatch>
                <LocationMatch "/jaxer-include/">
                        JaxerPassThrough on
                        Order Deny,Allow
                        Deny from all
                </LocationMatch>
                <Directory "/opt/AptanaJaxer/jaxer/framework">
                      Deny from all
                      <Files clientFramework*.js>
                              Allow from all
                      </Files>
                </Directory>
                Alias /jaxer/framework/clientFramework_compressed.js /opt/AptanaJaxer/jaxer/framework/clientFramework_compressed.js
                Alias /jaxer/framework/clientFramework.js /opt/AptanaJaxer/jaxer/framework/clientFramework.js
                <Directory "/var/www/www.example.com/">
                        DirectoryIndex index.php index.php3 index.html index.htm index.html.var index.html.var index.html.redirect
                        JaxerFilter html xhtml htm php
                        JaxerFilterContentType text/html
                        Order Deny,Allow
                        Allow from all
                </Directory>
                <Directory "/opt/AptanaJaxer/jaxer/aptana">
                        JaxerFilter .html .xhtml .htm .php
                        JaxerFilterContentType text/html
                        Order Deny,Allow
                        Deny from all
                </Directory>
                Alias /aptana /opt/AptanaJaxer/jaxer/aptana
        </IfModule>
</VirtualHost>

The only real difference is that we've removed the comments and included the port in the VirtualHost directive.

Once this is set up correctly, you can edit the start.sh in the /opt/AptanaJaxer/scripts to comment out the Apache command, restart Jaxer, restart Apache and you should be all set.

One possible point of confusion moving forward is the instructions about the REWRITE_RELATIVE_URL configuration command in the config.js file in the /opt/AptanaJaxer/jaxer/framework directory. The only thing you need to know here is that if your Jaxer instance is on the same server as the Apache instance using it, leave this commented out. This is for if an external server needs to access the items that are processed by Jaxer on this server.