Deploying Web Apps with REAL Studio Web Edition

Yesterday, REAL Software released REAL Studio 2010 Release 5. The big new feature for this release is that it now includes Web Edition, at least for those that own an Enterprise Edition license. If you don’t have Enterprise, then you can purchase WE for $600, but it probably makes the most sense to just upgrade to Enterprise.

Web Edition is pretty impressive for a 1.0 product. You can quickly build web apps using your existing REAL Studio skills. However, I’ve seen a lot of questions about how to run your web apps outside the IDE. There are three ways to do that: Standalone, Dynamic FastCGI and Static FastCGI. You can choose which to build in the Web tab of the Build Settings window. Static FastCGI is such a pain to configure that I’m not sure why it’s even there, so I won’t be discussing it.

Standalone

A standalone web app is simply a console application that functions as a very simple HTTP server. When you build this type of web app, you have to specify a port, usually some high number like 8100. You then run this console app and leave it open. On Mac OS X, the app will launch in terminal.

People can navigate to your site using the domain/machine name and the port. So if you’re running this on your MacBook Pro (which has an IP address of 10.0.1.3) then others in your local network can access it using http://10.0.1.3/8100

A standalone web app is pretty simple to work with, but because it is not a full-blown web server, you may not want to use for web apps that get significant traffic.

Note: There is a minor bug with the naming of a standalone executable. REAL Studio will always give it a fcgi extension, which doesn’t make sense for a standalone web app. This may even prevent you from running it. Simply remove this extension (at least on Mac OS X) so that you can double-click the web app to run it.

Dynamic FastCGI

For those not familiar with Apache or web technologies, FastCGI may seem like a complete mystery. But it’s really not that bad. I’ll describe what you need to do for Apache on Mac OS X Snow Leopard, other Apache installations (Linux, usually) may be slightly different.

  1. First, start Apache by going to your Sharing Preferences and checking Web Sharing
  2. Now you’ll need to use Terminal to edit your Apache configuration file. In Terminal, type
    CD /etc/apache2

    If you then type “ls” to see the files, you’ll see the configuration file “httpd.conf”. Make a backup first:

    sudo cp httpd.conf httpd.conf.backup

    and enter your password. Now you can fire up Pico with super user privileges to edit the file

    sudo pico httpd.conf

  3. You need to make a few changes to httpd.conf:
    1. Find the section that starts with
      <Directory "/Library/WebServer/Documents">

      In this section, add ExecCGI to the end of the line that starts with Options. Mine now reads:

      Options Indexes FollowSymLinks MultiViews ExecCGI
    2. Change the line that says
      AllowOverride None

      to

      AllowOverride All
    3. Add the FastCGI handler by adding this code:
        <IfModule mod_fastcgi.c>
          AddHandler fastcgi-script .fcgi
        </IfModule>

      This code can go near the other IfModule commands, but should not be nested in any of them.

  4. Now you can copy your REAL Studio web app to /Library/WebServer/Documents (don’t forget the Lib folder) and browse to it: http://localhost/MyWebApp.fcgi
  5. I prefer to put web apps in folders. If you want to do this then you’ll also need to add an .htaccess file to the folder containing the web app. If you web app is in a folder called MyWebApp, then the URL would be: http://localhost/MyWebApp/MyWebApp.fcgi. The .htaccess file contains just these two lines:
    Options ExecCGI
    AddHandler fastcgi-script .fcgi
    

If you want to put your web apps in folder other than /Library/WebServer/Documents, you just need to add a new Directory section to httpd.conf.

I have run into situation where the app just serves up a blank page. I’m not sure of the cause yet (I think it’s related to sessions not getting closed), but simply stopping and restarting Web Sharing fixes the problem.

Deploying to the outside world

Local testing is great, but if you want to share your web app with the world, you need to host it on a server that can handle internet traffic. I’m sure most people make use of low-cost shared hosting providers, such as Bluehost, FatCow, 1and1, etc (most of which use some variant of Linux). Unfortunately, I don’t think you’re going to have much luck getting REAL Studio web apps to work with any shared hosting provider. In order for a shared hosting provider to allow REAL Studio Web Apps to run, they will need to have FastCGI enabled and set up to run arbitrary apps in a specified folder (you won’t be able to run standalone web apps at all). I seriously doubt most shared hosting providers are going to want to deal with allowing apps written in a new, unproven tool to potentially crash their shared hosting. If you do find one that lets you do this, please be sure to let the community know. I’m sure we would all love to hear about it!

So right now your best options are to host your own server.

DynDNS

The cheapest way to get started is to simply use a spare computer at your home as a server and route internet traffic to it using a free account at dyndns.org. I’ve done this using an old Mac mini I have lying around. DynDNS allows you to route a domain name to your external IP address. You’ll then want to set up port forwarding to the specific machine being used. These are the rough steps that I used:

  1. Create an account at DynDNS.org and point it to my external IP address (provided to you at signup)
  2. I then needed to assign a static local IP to my Mac mini, which you can do in Network Preferences. Select Advanced and then TCP/IP. In the Configure IPv4 drop-down, choose “Using DHCP with manual address” and type in an address that is high enough that it will never get allocated by DHCP. I used 10.0.1.201
  3. Next I had to set up Port Mapping on my Airport Express. In Advanced, I selected Port Mapping and clicked Add. I then selected to send all traffic coming in via port 80 to the Mac mini (by entering its IP address 10.0.1.201).
  4. If you want to using a standalone web app running on a different port, then also map the port you are using instead of port 80.

You should now be able to access Apache on your Mac mini on the internet using your DynDNS URL. Mine is at http://logicalvue.dyndns-server.com

You can then launch standalone web apps on the Mac mini or set them up as FastCGI apps with Apache.

Go here to test a simple REAL Studio web app running on my Mac mini: http://logicalvue.dyndns-server.com/Test/WebAppTest.fcgi

Note: You’ll only be able to access my Mac mini when I actually have it on. Since this is only a test server it is not on 24/7. If you get a “server not available” message, that’s why.

Virtual Private Server/Colocation

If you’d rather not or cannot host your own server, then you’ll need to have someone else host it for you. Most affordable are Virtual Private Servers (VPS) which use virtualization techniques to give you your own server (usually Linux) that you can manage on your own and do with what you want. Hosting companies offer a wide variety of packages, which I’ve seen starting at about $20 a month or so. I’m currently investigating three different ones and will report back with results:

  • Dreamhost with VPS ($24/month): Dreamhost has a free 1-week trial, so I’m testing it this week to see if I can get it to work with REAL Studio web applications
  • MyHosting LAMP Developer VPS ($20/month): I like their pricing, but haven’t heard back from my sales inquiry yet
  • InMotion VPS ($40/month): A user on the NUG has reported that this hosting works with REAL Studio web apps

A final option it to have someone host your hardware for you. If you have a Mac mini, then Mac mini Colo and Mac mini World seem like affordable ways to use it as a server (starting at $35/month). I’ve not used either.

I hope you found this useful. Feel free to ask questions in the comments; I’ll help if I can.

Update 1: MyHosting is no longer an option. Although their prices were great, all their Linux VPS plans use 64-bit Linux and they do not let you install the 32-bit compatibility libraries needed for REAL Studio.

Update 2: I have DreamHost with VPS working!! Check it out here: http://www.pharmacaidonline.com/WebAppTest.fcgi

9 Responses to “Deploying Web Apps with REAL Studio Web Edition”

  1. Chris Tolley says:

    Thanks for this article. It’s very useful!

    I just signed up to Dream Host (with a shared server) and have had no luck. After reading this I see I should have stated with a VPS.

    Please let us know how you make out with the different hosting companies.

  2. Paul says:

    @Chris,

    I doubt you’ll get DreamHost with shared server to work. I’m still trying to get a DreamHost VPS to work, but no luck so far. You can add the VPS to your account to test it (first week is free). You can also get your money back with DreamHost for up to 90 days.

    • Chris Tolley says:

      Congrats on getting DreamHost to work for you! I’ve opened an account at Hostingrails now and am bashing my head against a wall.

      If I give up there I might go back to DreamHost and see what I can do with their VPS.

      Thanks again on the great article.

      Chris.

  3. Chris Tolley says:

    @paul

    Congrats on getting your DreamHost VPS to play nicely with Real Studio Web!

    I upgraded my plan to VPS but I’m still having some problems.

    Any chance you could share with us the steps you took to get it to work?

    (fyi: my problem is that I’m getting a time-out error in my log. I’ve made sure my .fchi file is executable and the whole folder housing my http files are group writable and executable. What kind of magic did you do to get things working for you?)

    Thanks in advance for any insight you can share.

    Chris.

  4. Chris Tolley says:

    Woops- just noticed your latest post covers this – please ignore the above – will read now. Thanks.

    Chris.

  5. Rich Morgan says:

    I have a hosting company specific for RealStudio Web Edition users and will be taking new accounts on Monday. Do you mind if I post the information for that here?

    • Paul says:

      Not all all. Please do post it here. I’m sure lots of REAL Studio users would be interested in this!

      • Rich Morgan says:

        Thanks and I hope it does help all RS WE users hitting this hosting bottleneck. I’m provisioning the servers now and taking new accounts as fast as they are plugged in. It’s a dedicated environment for RS WE FastCGI applications. $19.95 for unlimited bandwidth, ftp and ssh shell access, Debian Linux with 32-bit libs, 24/7/365 support, free domain name support, free account setup. Basically all a WE user needs. ;-)

        Call us to reserve an account – 888-382-8131.

      • Rich Morgan says:

        Just a quick update – our site is up and we are officially setting up user accounts. Visit fastcgihost.com for the details and call me when you’re ready to begin with your account! :-)

        Thank you,
        Rich