Editing XML config to set up Litespeed/Rails

Discussion in 'Ruby/Rails' started by thomasn, Jul 13, 2007.

  1. thomasn

    thomasn New Member


    I'm trying to get Litespeed 3.1.1-std set up on a shared host, and as I do not have SSL enabled I want to use just an ssh commandline (to avoid sending admin passwords over HTTP). I am going nuts trying to use the admin UI with the "lynx" text-mode browser -- I can see the UI ok, but it is not at all easy to use. Are there instructions somewhere for setting up virtual hosts and a simple ruby-lsapi Rails config by just editing the XML conf/* files? Or do I have to create an identical config on a local machine and then copy the XML config files across?

    Litespeed+LSAPI is really useful as a fast, low-footprint server for Rails, but I haven't yet found admin-level docs that tell me which config files to edit to set up Virtual hosts etc. Can anyone point me in the right direction?

  2. nathanc

    nathanc Well-Known Member

    Yes I agree with you. I wish the rails side was more documented.
    What I recommend, is that you setup a VHost Template.

    These are simply suggestions coming from my humble opinion.

    Files in question here are:
    ./conf/template/test_rails.xml <-- defines how your VH template behaves
    ./conf/httpd_conf.xml <-- Defines Server wide settings and which template a domains is assigned to.

    You will find that ./conf/httpd_conf.xml is pretty key to what you are looking for.
    You should however use the build in UI to do the initial setup of your server.

    == Initial setup ==
    Step 0: Configure Server > Ruby On Rails.
    Here you define the behavior of each rails app.

    Step 1: Add a new VH Template through the control panel.
    My setting for this example are:
    Template Name Test_shared_solution
    Template File /opt/lsws/conf/templates/test_rails.xml
    Mapped Listeners port80

    Step 2: I had to create the "test_rails.xml"
    "touch /opt/lsws/conf/templates/test_rails.xml"
    you may have to change permissions of this file.
    Im not sure why saving an new templates doens't create this
    file for us if it doesn't exist.

    Step 3: Edit your new VH template. You will see alot more settings now.
    Heres an example of the "General" tab of my test_rails app:
    Virtual Host Root $SERVER_ROOT/$VH_NAME/
    Config File $SERVER_ROOT/conf/$VH_NAME.xml
    Max Keep-Alive Requests Not Set
    Smart Keep-Alive Not Set
    Document Root $VH_ROOT/public/
    And the best way to add rails capability to your template is to
    use the Rails context. This takes up to step 4.

    Step 4: Add a rails context.
    Heres another example from my test_rails app.
    URI /
    Location $VH_ROOT/
    Rails Environment Production
    Max Connections 5

    Step 5: Security.
    On the security tab I changed the,
    ExtApp Resource Control > ExtApp Set UID Mode = DocRoot UID
    Reason you would want to do this is, because if you want
    the rails to run under the UID of your client, instead
    of the default nobody:nobody. Plus the LSWS has to be able
    to write session data inside the rails app/.

    ExtApp Set UID Mode DocRoot UID
    ExtApp Chroot Mode Same as Server
    ExtApp Chroot Path Not Set

    == EDIT OF THE httpd-conf.xml file ==
    Once you have the initial setup of the server done you can, add new domains
    via an edit to httpd_conf.xml. Let me explain that a bit.
    Inside the xml file at the bottom you will find:
    <name>Test_shared_solution</name> <<< This is the template we setup.
    <vhName>onsale.c0m</vhName> <<< We are assigning this domain to Test_shared_solution template

    == Summary ==
    once you have it setup, its pretty easy to add new domains.

  3. thomasn

    thomasn New Member


    Marvellous, thanks a lot. I have it working ok using the 'External LSAPI App' approach, so perhaps if I work on merging my directions with yours, we might get something we could add to the wiki?

    Not this weekend, though :)

  4. nathanc

    nathanc Well-Known Member

    Im would be happy to put some notes together for some stronger documentation.

    Are you using templates with your external app setup? If so how did you setup the command fields which is to point to the dispatch.lsapi? Are you manually copying in the dispatch.lsapi in to your clients rails directory?
  5. mistwang

    mistwang LiteSpeed Staff

    The easiest solution is using our Rails vhost template, it is based on our easy configuration.

    Our Wiki should be editable by any forum user. Feel free to and your doc there.

Share This Page