One organization I do a lot of work with hosts their sites on a 1&1 Managed Server. Essentially, only their sites and applications are running on the server, but 1&1 manage all of the sysadmin work, and don’t provide root access. I have a number of misgivings about the configuration of the server, particularly the fact that the user’s root folder is also the document root for their main domain, but 1&1 have been good about keeping PHP up to date, and we don’t have to worry about being woken at 3am to fix stuck processes. Unfortunately, Ruby hasn’t been treated to the same attention as PHP and the system version is still languishing at version 1.8.1, which won’t handle rails for us.
We entered into a round of emails to try and persuade 1&1 to upgrade ruby for us, and maybe even install gem and rails system-wide, but after a number of confusing messages where it wasn’t clear whether their answers actually applied to the plan we were on (“you need a linux server for that”/“we have a linux server”, “you need a dedicated server”/“we have a dedicated server”) we gave in and I realised that if I wanted rails I’d have to install it myself.
It turned out to be a very straightforward process. Compiling ruby and gems with appropriate prefixes (./configure –prefix=/my/preferred/folder) got them in place, and from there I was able to install the rails gems. It’s important to check that your installation folder is blocked by the web server and to put a relevant .htaccess file in place if not. You don’t want a curious visitor or malicious attacker playing with your binaries. You’ll also want to add your new bin folder to your default path by editing your .bash_profile file to add a line like:
export PATH=~/usr/bin:$PATH
With that done, changing the shebang in dispatch.cgi was enough to get the application up and running using CGI, which was enough for us to start testing applications, but would quickly become too slow once those apps are in production.
FastCGI can be activated through the ‘Server Administration > Advanced Settings’ option in the control panel. I did that, and then tried to install the fcgi gem:
gem install fcgi
It installed successfully, but building the documentation threw a sequence of errors about undefined symbols. Unfortunately when I switched my .htaccess settings so that FastCGI I received an ‘application could not start properly’ error. Being short of time, and having rails frozen into my application directory, I decided to go in and edit [APP]/vendor/rails/railties/lib/fcgi_handler.rb directly, changing
require 'fcgi'
to include the full path to my newly installed fcgi gem.
That worked, and I now have a working, fastcgi-based rails application running on the server.