Since I upgraded to Typo 4.0, and in the process rails 1.1.6 I have had a few occurrences where nanoRAILS would hang, several bloated processes would be sitting there and not respond, and the only option at that point was to kill all ruby processes once I realized what was happening, which could be several hours. Suffice it to say, this is not a good option.
So after struggling during last rails upgrade to 1.1 on my host, the next logical step is to also use my own version of ruby so I can have better control on its environment, and even apply patches if necessary.
The following steps apply on a lot of systems. More specifically, my host is DreamHost (aff), and as best I can tell, I’m on a host with Debian Sarge.
Build your own Ruby
Download ruby from http://www.ruby-lang.org. The latest version is currently ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz
Create the makefile using
./configure prefix=[YOUR_OWN_RUBY_PREFIX]
Since you most likely don’t have root access, you need to override where ruby think it resides, and the way to do that is to set the prefix to somewhere into your home directory. Something like /home/USERNAME/ruby for example. From that point on, libraries, other builtin ruby files, gems will automatically install into your own ruby repository so you never have to worry about getting in trouble with an unforeseen upgrade.
Optionally, you can apply the patch used by Railsbench, with hardcoded default values because I haven’t figured how to set the environment variables for the dispatch.fcgi process (since apache in my case determines that). Download my version of rubygc.patch .
patch gc.c rubygc.patch
Build and install ruby
make make install
Additionally, so that the command line uses the same version of ruby, add this to your .bashrc or equivalent for your shel.
export PATH=[YOUR_OWN_RUBY_PREFIX]/bin:$PATH
Install your own gems
Now you are ready to install your own gems. Here’s the bare minimum you need.
First, install rubygems
wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz tar xzvf rubygems-0.9.0.tgz cd rubygems-0.9.0 ruby setup.rb
Then install the minimum set of gems:
gem install mysql gem install fcgi gem install rails --include-dependencies
Now, the only thing you need is to change the path to ruby in your dispatch file (dispatch.rb for mod_cgi, dispatch.cgi for regular cgi, and dispatch.fcgi for FastCGI/fcgid)
Typically, replace
#!/usr/bin/env ruby
by
#![YOUR_OWN_RUBY_PREFIX]/bin/ruby
Replace [YOUR_OWN_RUBY_PREFIX] by your own value you used earlier.
That’s a simple and excelente idea, the puts you in much more control of your instalation.
Yes, indeed. And so far, the troubles from yesterday seem to be gone. Still crossing my fingers :)
I installed my own version of Ruby and Rails/Gems on dreamhost but I still get the problem where the first request (after some idle time) takes up to a minute to load. I think this may be caused by Apache loading up the initial FCGI processes but I am also looking at my own app for slow points.
Do you have any ideas (other than what’s on Dreamhost’s wiki) why this would be? Also, when will Dreamhost wake up and put mongrel on their servers :)
David, I don’t seem to have this problem, but maybe just because I have request coming in often enough. I have heard of people adding a cron entry (using curl, you could use wget as well) to periodically wake up their server. You can check using _ps -eaf_ or _top_ whethher you have any _ruby_ or _dispatch.fcgi_ still running. If you do, then it should work (unless their are hung of course, but in this case you would get a 500 error after 120s).
I wish dreamhost would support mongrel as well, or let us use proxying so we can run whatever we want.
There is a page on dreamhost where you can cast your vote for mongrel support: [Vote for Mongrel on DreamHost](https://panel.dreamhost.com/index.cgi?tree=home.sugg&category=Software%20Installations&search=mongrel)
When i first started using ruby I installed my own also. Then I became less interested in doing so when I could just apt-get it and it had things mostly the way I wanted them. the occasional configs here and there I find myself wanting but apt packaging has most everything a-ok. – ben @ http://rubyonrailsblog.com/
Ben, I would indeed rather use apt-get. The point in this case though is that on a __shared host__ you can not use it (since you don’t have root access), and furthermore, you want better control as to when your environment changes as opposed to when your host decides to make the change.
Does this still hold true? I followed the post to the letter, but now I get a Rails application failed to start error.
I’ve killed any running fcgi just in case.
Mark, your application can fail to start for a number of reasons. Check the web server log (apache?), at least the part your host provides, check your rails/log directory for any hints.
Lastly, you can call your dispatch.fcgi and you might some errors you can not see in the logs.
Depending on the error, you would have to figure out what the next step is.
If you can’t figure it out, post any error you see here and someone might know a solution
I tried using your patch but two of the hunks were rejected and kept the install from running. Is this a problem with Ruby 1.8.5?
I have not applied this patch to 1.8.5. What are the bits that cause problems?
I tried these steps on 1and1.com shared linux developer package. It did not work when I created a rails skeleton and navigated in a browser to the root of the app. I get a 403 forbidden error in the apache log.
[03/Jan/2007:20:12:18 -0500] “GET /sandbox/rails/blog/ HTTP/1.1” 403
Perhaps some steps were left out? Some permissions changes?
Thanks,
Ed
first, you need to make sure the absolute path to ruby is the right one. Then you can try running dispatch.fcgi by hand, you may learn something interesting.
Next is to check the error.log for apache (assuming that’sone 1and1 uses). Also of interest is to check the ruby on rails log (development or production depending on how your setup is). Some of these logs are bound to show some error.
Does the dispatch.fcgi get run as your user id? It is not, that may be a permission problem (403 is “forbidden”, usually).
I tried to do that with my advantage netfirms.com host account. It gives me:
bash: ./configure: /bin/sh: bad interpreter: Permission denied
bash: make: command not found
I tried in both /cgi-bin/ and /www/ subdirectories with the same result.
By the way, they use pretty outdated ruby and rails:
ruby -v
ruby 1.8.2 (2004-12-25) [i386-freebsd4.10]
hmm, this does not look good. No sh? no make? Are you sure your $PATH variable is set correctly?
Does not look good indeed. You should be able to override your profile by creating a .profile (or .bash_login) file in your home directory (~)
Since the system appears to be freebsd, you may be able to find binaries of make and copy them over, but it may be time for a new home…
For the long run, yes, I better find the more friendly host, but, actually, I got this deal as $10/yr plus 2 free domains, so, if I leave I have to pay for domains anyways.
Seems like a good idea of yours to try to find binaries of “make” and what not and copy them over to my local directory! Unfortunately, FreeBSD used by provider is pretty old (4.1), and freebsd.org has moved it to
this archive, and it is restricted by passworded by some unclear weird reason!
Because all I need so far is to extract the “make” binary, I found
another resource, but I don’t actually know where can I get the desirable “make” among all those file.
Sorry I’m too desperate to install my RoR applications on even creepy host, and also feel guilty to distract you so often. I think my case is too “unusual”. But who knows what iif a lot of netfirms.com users want to do the same? RoR is very popular, and gains more and more each day, deminishing ubiquitous PHP — pretty soon such providers without good RoR will be out of business or forced to upgrade.
Probably, for me, it would be just easier to go to with hosts already supporting Mongrel and Ruby (no need in fastcgi etc):
Still, I feel like I can win a real freedom, if even being prisoned in the cell of the jailed shell provided by netfirms.com, I could install mongrel and the last rail and gems. After all, any host can change something and never give me root (which I actually don’t need). So, your ninja skills you shared with us, are pretty valuable, no matter what. All I need is the plans with shell access, and it’s pretty attractive to install the latest and the greatest and customized for yourself as if almost you have dedicated server.
Thank you in advance!
It is sounding worse by the minute. You may really be out of luck, but it is true that the price sounds hard to beat.
Just out of curiosity, did you try to work with netfirms support? Maybe they can help you with part of it?
It would be nice to find the ready-made binary of “make” for i386-freebsd4.10. But I’m not sure it could be enough to successfully compile anything inside my local directory because of dependencies etc.
netfirms.com “support” is a joke. You’re lucky if after waiting for a week or two, somebody (probably from sales) just refers you to their scarce and buggy 1 page manual.
I’m under impression that nobody really uses Ruby on Rails on netfirms.com. Actually, netfirms.com is not bad hosting — they provide you not only *nix with PHP/Perl etc,, but also .NET/Windows platform. Could be handy in some case if you have such customers
I am going to try couple of my old ASP.NET 2.0 projects next week then, but, as a matter of fact, after working with Ruby, I hate to look back to Java/C# strong-type languages.
Well, good luck with it!
I am a novice on Rails but can you not freeze the local version of rails and then upload it on the server…that ways you will never have versioning issues…have a look at the link please
http://www.andhapp.com/blog/Rails_Input_output_error_on_linux_/35
Is this not a good solution???
Yes, this is part of the solution. rake rails:freeze:gems will only freeze rails and it is also recommended to free your other gems. There are several solutions. I like to use RIck’s solution: [Gem plugin](http://svn.techno-weenie.net/projects/plugins/gems/README)
Hi.
Good design, who make it?
The design is based on Richard White’s Bright House Theme (http://www.height1percent.com/)