LSAPI and Shared Hosting not working

The wiki regarding RoR in a shared environment is pretty short:

It says to enable the 'Rails shared hosting', it doesn't even go into detail about installing Rails or the LSAPI, one presumes that comes from the other two guides.

However, having done the install, enabled the shared hosting for rails, the error_log show:

2012-11-19 15:36:51.291 [INFO] [] connection to [/tmp/lshttpd/] on request #0, confirmed, 0, associated process: -1, running: 0, error: Connection reset by peer!
the stderr log shows:
2012-11-19 15:36:51.622 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `require': cannot load such file -- config/environment (LoadError)
2012-11-19 15:36:51.622 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `<main>'
2012-11-19 15:36:51.974 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `require': cannot load such file -- config/environment (LoadError2012-11-19 15:36:51.974 [STDERR] )
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `<main>'

This file does exist, and actually if you strace the lsws process it shows the file being accessed at the RoR application location within the user account.
926369 open("config/environment.rb", O_RDONLY <unfinished ...>
926369 <... read resumed> "# Load the rails application\nrequire File.expand_path('../application', __FILE__)\n\n# Initialize the rails application\nRor::Application.initialize!\n", 147) = 147
Anyone have any suggestions here?
Thanks, that worked, but now there's another error:

2012-11-21 10:02:53.833 [STDERR] /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- initializer (LoadError)
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:133:in `<main>'
Looking at line 133, it's another 'require':

    require 'initializer'
Last edited:


LiteSpeed Staff
Looks like there is no enough information for litespeed to detect the version of Rails being used, and it defaults to Rails 2.3 branch of code.
If the Rails app involved is >2.3 release, you should set "RAILS_GEM_VERSION" variable in "config/environment.rb" explicitly for that application.
Thanks, again another error:

2012-11-22 09:08:33.770 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require')
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'
2012-11-22 09:08:33.771 [STDERR] cannot load such file -- lsapi (LoadError2012-11-22 09:08:33.770 [STDERR] : 2012-11-22 09:08:34.346 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require': cannot load such file -- lsapi (LoadError)
2012-11-22 09:08:34.346 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'
2012-11-22 09:08:34.920 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require': cannot load such file -- lsapi (LoadError)
2012-11-22 09:08:34.921 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'
I'm surprised by the amount of problems getting this working. Would you consider the ruby LSAPI to be production ready?


LiteSpeed Staff
Those errors are due to Ruby/Gem/Rails update. It was working well in production for many years.

For the "require lsapi" error, you need to locate the gem folder, like

Just follow the instruction in README to manually install it into ruby system folder, it can be always located by ruby.
Thanks. That has resolved the error, however there is a further error now:

/usr/local/lsws/fcgi-bin/RailsRunner.rb:91:in `<main>': uninitialized constant RAILS_ROOT (NameError)
2012-11-27 12:22:51.283 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:91:in `<main>': 2012-11-27 12:22:51.283 [STDERR] uninitialized constant RAILS_ROOT (NameError)
Since this is due to a Ruby update, will you be issuing a revised version of the Ruby LSAPI runner?


LiteSpeed Staff
Yes, there is a updated version of RailsRunner.rb, please manually upgrade to 4.2.1 release with command

/usr/local/lsws/admin/misc/ -f -v 4.2.1
That seems to have done the trick, thanks. I think I might be seeing this problem:

In so much when running as development and the moment you try to add a route and remove the public/index.html it doesn't actually recognise the changes and actually doesn't even pass the request to the rails handler.

In fact, the HTTP header returns:
X-Powered-By: PHP/5.4.8
and you can see lsphp5 being run.

Adding any non-existant route such as /foo/bar to the request results in a proper Rails-handled request. It's just when requesting the root of the app that nothing happens.
I've tried this, and other .htaccess directives, but the .htaccess inside the app/public directory and also within the public_html root seems to be ignored.
It's giving a 403 because I disabled indexes, as you suggested here. This had to be done on a global default level, since .htaccess in the public_html root is not considered by the server.

I should add this is a standard cPanel CentOS machine, running LSWS, if this helps.

Requesting any URL except the website root works, eg. /foo/bar results in a Rail error saying no route (as expected). Requesting / just results in a 403 due to Indexes being disabled. The request response headers in each case are different, it's clear to see that the request for the website root is not being processed by Rails (and indeed there are no ruby processes spawned by LSWS).

So considering indexes are disabled at the moment, should I be leaving them disabled, or enabling them. As it stands, any request for the web root (public_html) is not being passed to the Ruby LSAPI.