deploy ruby or rails on windows [duplicate] - ruby-on-rails

I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.

Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.

Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.

Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.

The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well

I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.

You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.

Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.

Related

Creating a Ruby on Rails environment on Windows, in a VM Vagrant Box

Is Vagrant a good solutions for creating a Rails environment in windows?
I have a powerful Windows 8 64bit desktop. I recently did a project with RoR and fell in love with it. As I found out, installing RoR on windows is just bleh; so I created a dual boot to ubuntu. As a creative developer, I find it rather difficult to get any of the "creative" done in ubuntu because of the lack of my typical creative tools.
I read a bit about a tool called Vagrant; however, I'm still unsure if it meets my requirements: adobe suite, sublime text, git, rails, rails friendly OS(mac?/ubuntu)
Typical duties: edit an image in photoshop(windows), drop it to project assets in VM?
Typical duties: push/pull to git; ssh to VPS server?
Also, I hear you can install mac os in the VM do you think thats a good option? (because I want to try their new OS)
Installing osx in Vagrant is probably possible but it would likely be quite hard, and its not really what vagrant is designed for.
As for your other questions vagrant sounds like the perfect fit.
With Vagrant you could start up an ubuntu vm and get your rails setup going. Then you could just forward a port on your local machine to the vm and load the rails site as if it were running locally on your windows PC. A quick google gets this vagrant box that looks like it might work for you - https://github.com/amaia/rails-starter-box
To work with the site you can just share a folder between the vm and your local machine which will allow you to edit images and code with your windows apps (Photoshop, sublime) so you don't actually need to install these in the ubuntu vm at all, and can pretty much work as normal.
Git is much the same... I prefer to SSH into the vagrant box and use git on the command line in ubuntu but you can just as easily use gitbash or tortoisegit from windows in the repo folder... works just as well.
A good alternative is, https://github.com/fgrehm/ventriloquist
"Ventriloquist combines Vagrant and Docker to give developers the ability to configure portable and disposable development VMs with ease. It lowers the entry barrier of building a sane working environment without the need to learn tools like Puppet or Chef."

No up to date guides for installing latest version of Rails on Windows 7

I've looked around the current answers for similar questions but still couldn't find the information I was looking for.
While there are countless guides to setting up rails, it seems there aren't that many which are up to date. The latest installation of Ruby 1.9.2 seems to come with RubyGems but I can't seem to install it by running the command gem install rails
On top of this I've read guides recommending to establish a linux environment. I'm even confused to what database to use "SQLite3" or "MySQL".
My question, is how the heck do I get Rails installed quickly on Windows 7, what database should I use with it and also whether it's worth installing a VM? Any up to date guides would also be appreciated. I'd like to have the most suitable environment to get started.
I started out with Windows, used Ruby/Rails for a month, then decided to go with Rails on Ubuntu under VirtualBox, using Putty to remote to it.
MySQL is installed on Windows (so that the VM doesn't become too slow).
All code is on VBox accessible Windows drive, everything else Rails-related is on Ubuntu.
All this lets me:
Use Ruby/Rails in it's "native" place i.e. *nix
Use my Windows 7 slick (IMO) GUI
Use my BeyondCompare, TortoiseGit
Learn linux (as mentioned below also)
Ask better questions / get more answers in the community (where everyone assumes ;) that you've either got Rails on Linux or a Mac) since everyone seems to be using *nix.
To me, it makes sense to not use Ruby/Rails on Windows, especially since hosting a Rails app will 99.999% be on a linux box. So, you will get to learn linux/Ubuntu and can be better prepared come hosting time. Bonus in resume + you won't be lost when asking questions down the road, and not wonder "is this problem installing this gem because I am using Windows?".
Also, I noticed that running things like rake was 2-3 times faster in Ubuntu than in Windows. And now I think it is good to have learnt linux. I must say linux excels at the command line, and I kind of like using it now. Linux/Ubuntu sucks at GUI (IM very strong O!).
Oh, and for Ruby/Rails on Windows, give Pik a try (it's the Windows version of RVM - Ruby Version Manager).
And just for the record, on Windows, I faced problems with installing RSpec; exceptions in WebBRICK; could not use imagemagick; and other small things I am glad to have forgotten.
The Rails Installer has recently been updated for Windows, and has the support of EngineYard to keep it up to date. But, it looks like it only installs Ruby 1.8.7 at the moment. But, it should be a good starting point.
You can read Engine Yard's announcement, and reasoning for getting the Rails Installer up to date here: http://www.engineyard.com/blog/2011/introducing-railsinstaller/
The problem with Windows is it's totally different than all the other OS's. Supporting it requires all this if WIN32 else business that's no fun at all, so support lags. And since no self-respecting developer would even want to run Rails on Windows, there's just very little incentive to keep support up to date.
Why not get a hosted Linux VM such as one at Slicehost and run your project there? The advantage of that is it's accessible from anywhere without having to set up port forwarding on your cable modem (assuming you have a static IP.)
Rails on Windows is poorly supported. And even if you can get the basic Rails environment up on Windows, you'll face various problems with many Ruby gems--they aren't tested in the Windows/Rails environment so they often have problems.
Alternatives
I use a windows machine for developing Rails apps. But I never run the apps on my win box. I did it once a couple of years ago but found it to be a waste of time since many ruby gems don't work properly on windows.
Instead, I run Linux on an old PC as my development environment. I use Samba to mount the Linux box's filesystem on windows. Then I can use Windows text editors such as UltraEdit.
Another option that doesn't require a second machine is to load Linux on a secondary partition on your windows box. You can then boot into the Linux os and run Rails there.

How to use a VM to create a Rails staging environment

My app is in development and I do all my testing using WEBrick (I like the terminal output).
On the production server it will run on Phusion Passenger.
I'm running Snow Leopard and wish to test the app in an environment similar to the production environment.
Can I use Parallels to run a Debian install with Apache and Passenger and configure Capistrano to deploy to that?
Thanks!
I have been using VMware for that sort of thing. Its really easy to deal with network wise. I have recently switched to Virtualbox which is much nicer to actually work in (at least for me), does the same things, and is free. Download the Debian iso and create a new VM that uses it as its CDrom. Thats about all you need to do. Good luck.
This may not be the answer you're looking for but I've found it very straightforward to just run passenger locally for development. You can always tail the development.log, it's really just as easy as watching the terminal output from webrick.
Dev setup is made all the easier with the drag and drop ease of the phusion passenger pref pane.
http://www.fngtps.com/passenger-preference-pane
Seems like it would be easier than setting up the VM and all. Though yes, there could still be differences if your not hosting on OS X server I suppose.

Limitations in running Ruby/Rails on windows

In the installation documentation to RoR it mentions that there are many limitations to running Ruby on Rails on Windows, and in some cases, whole libraries do not work.
How bad are these limitations, should I always default to Linux to code / run RoR, and is Iron Ruby expected to fix these limitations or are they core to the OS itself?
EDIT Thanks for the answer around installation and running on Linux, but I am really trying to understand the limitations in functionality as referenced in the installation documentation, and non-working libraries - I am trying to find a link to the comment, but it was referenced in an installation read me when I installed the msi package I think
EDIT
Thanks for the references to IronRuby lately, it is certainly a project to watch, and as it, obviously, is a .NET language, it will be invaluable if it lives up to the promises. Eventually, however, in my case, I just bit the bullet and installed an Ubuntu server.
<bias> I should've done it years ago </bias>
Here's an overview of the current issues with Rails on Windows:
Ruby and Rails are slower on Windows than they are on Unix-like OS's.
A few gems and libraries don't work on Windows.
Some Unix-isms aren't available on Windows (examples).
The community is mostly on either Mac or Linux (This is a particularly hard one to deal with; nobody wants to be alone on one island when the rest of the tribe are partying, having fun and getting along great over on the other island. Community is important. It seems that most Windows developers that start with Rails quickly switch to a Mac or Linux. However, the small community of Windows Ruby users that do persist are extremely friendly, dedicated and knowledgeable - go say hi.)
Note much of the advice that follows is now outdated due to the magnificent efforts of the RubyInstaller team in bringing stability, compatibility and performance to Ruby on Windows. I no longer have to use VirtualBox, which says a lot about how far Ruby on Windows has come.
If you want more technical detail, the following are required reading. :
Ruby for Windows - Part 1
Is Windows a supported platform for Ruby? I guess not
Testing the new One-Click Ruby Installer for Windows
Still playing with Ruby on Windows
Chatting with Luis Lavena (Ruby on Windows)
Choice quote from that last one is:
AkitaOnRails: The most obvious thing is that any Gem with C Extensions without proper binaries for Windows will fail. Trying to execute shell commands will fail and RubyInline as well. What else?
Luis Lavena: Hehe, that's just the tip of the iceberg
Having said all that, I don't find developing with Rails on Windows too painful. Using Ruby is, for the most part, a pleasure. I'd avoid InstantRails because, to be frank, it's just as easy to install Ruby properly using the one-click installer, then doing a gem install rails. If you need Apache and MySQL, WAMP is a good bet, although even these aren't required if you just stick with Mongrel and SQLite.
What I've taken to doing recently is running VirtualBox with an instance of Ubuntu Server that closely mirrors the deployment server. I map a network drive to the Ubuntu Server, then I edit and run my code directly on the VM. It uses hardly any memory (it's currently using ~43MB; contrast that with Firefox, which is using ~230MB) and Rails actually performs better than running it natively on Windows. Plus you can experiment with your virtual server in relative safety. It's a really nice setup, I highly recommend it.
Finally, here are a couple of Ruby/Rails blogs aimed at Windows users:
DEV_MEM.dump_to(:blog) (Luis Lavena)
Softies on Rails
Ruby On Windows
I found getting a development environment up and running with Instant Rails on Windows was really simple. Especially when using Netbeans or Radrails as the IDE.
Less than a 10 minute job.
What did those who struggled find to be the problem?
I've been developing Rails on a Windows PC for a couple of years and had no real problems installing back when I first started. However I recently re-built my machine and struggled to get the One-Click Ruby installer working and the latest version of Gems. So this is what I tried.
Option 1: Run a Linux Virtual Machine
I was really impressed with Charles Roper's idea of running Rails within a Linux virtual machine, and this is the route I intially went for. It all went pretty smoothly and I've been documenting it at budanters.blogspot.com. However I've been struggling with accessing the MySQL server (in Linux Virtual Machine) from the Windows host.
Option 2: Use jRuby
I recently installed the Windows version of NetBeans 6.5 Ruby bundle, and without being aware of it, this installs JRuby and the Rails gems. The IDE has a UI to install Gems, and I've now got my old application back up and running in my development enviromnent.
Update November 2009
I now use Netbeans 6.7 on Windows and in the whole I am very happy with it. The only downsides are that it installs JRuby 1.2, and I needed to install JRuby 1.3 manually to get something working (I can't remember what) and I have been completely unable to get deployment working with either Capistrano or Vlad the Deployer to work. Vlad uses Open4 which doesn't work with JRuby.
Update May 2010
Netbeans 6.8 comes with JRuby 1.4 so no longer have to fiddle around with manually installing JRuby 1.3. Also it seems that in JRuby 1.5 Open4 will now work, which means Vlad might start working.
Nobody mentioned Bitnami RubyStack yet? I've been using it for years, together with RadRails. Includes Apache, MySQL/Postgre, phpmyadmin, git etc. Optional Ruby 1.9.2/Rails 3.0b. You may also run the Ubuntu flavor of RubyStack in a VM but I haven't tried that yet.
There is a packaged installer available at http://railsinstaller.org/ which is worth checking out.
Personally I found getting Ruby + Rails up and running on windows a piece of cake. From download to browsing to my first 'HelloWorld' app took me all of 15 minutes. I didn't even bother with any of the InstantRails stuff.
Subsequently I can't say I encountered any of the reported speed problems or issues with Gems under Windows.
These guys also do a nice Ruby developers add on for Visual Studio:
http://www.sapphiresteel.com/
When I last fiddled around with Rails on windows, I used Instant Rails and found it to be a fairly painful process, except for the lack of updates to Instant Rails (which, from the look of the website is still a little bit of a problem, as instant Rails 2.0 uses ROR 2.0, while the newest version is 2.1). You might also look into the answers to this question as it mentions a number of other ways to get RoR running on windows easily.
You have windows options for getting everything up and installed, such as Instantrails:
However, my personal experience with trying to get colleagues up and running on windows is that it's a pretty painful experience. You should be able to get most (if not everything) running, but be prepared to spend a bit of time mucking round (and getting frustrated).
YMMV
I would probably recommend either Linux or Mac for rails development (but I'm slightly biased against windows, so you may need to take that with a grain of salt).
An option if you're stuck on Windows is to have virtual servers running Linux / BSD / what-have-you.
It solves lots of other problems also (allowing you to try multiple server configurations easily, etc.).
If you can't get away from windows use VMware and run some form of linux (ubuntu is popular). Your No.1 limitation will be compiled gems which do not play nicely on windows.
The majority of tutorials assume you're on some form of *nix, it's when you start to break outside of basic scaffolding when you'll feel the pain. Image manipulation, full-text search and even some db adapters will either only run on *nix or are a pain to setup.
The majority of web hosts run linux too, it's good to be developing on the same platform as your host, to avoid deployment headaches.
In general, Rails performance is a problem on Windows.
As far as your deployment setup, you can either run Rails in FCGI or use mongrel (and set up either Apache or IIS as a proxy). mod_rails (http://www.modrails.com) is the best deployment option for Rails today, but doesn't run on Windows.
You might find more luck using JRuby on Windows to run Rails in whatever JVM environment you want (tomcat, J2EE server, etc).
IronRuby isn't there yet to run Rails in a production environment, but eventually it will be aimed at running Rails inside any ASP.NET environment (IIS).
You could just use Cygwin and it's version of Ruby. That gets rid of the arguments about compiled gems not working on Windows - I've managed to compile a lot of gems that way.
The biggest limitation of running under Windows is that a lot of things are super slow.
See this thread. For a discussion.
Simple things like "script/console" and running rake tasks will take 5 times longer on Windows than they do on Linux or Mac.
Other limitations are:
No IE6 on Vista.
BackgroundRB and a many other c based gems do not work on Windows.
No passenger
I'm not a rails developer myself but I thought this may be of interest. Microsoft has released IronRuby 1.0, it's a version of Ruby that runs on the .NET platform that apparently runs 4x faster than the official Rails implementation on Windows.
http://www.drdobbs.com/open-source/224600662
Official site
http://ironruby.codeplex.com/
For a speedup you could try my loader speeder upper (helps rails run faster in doze): https://github.com/rdp/faster_require
Also checkout spork, which works in doze
Alternative of RailsIntaller is RailsFTW. The Ruby & Rails are more updated.

Is there anyway to run Ruby on Rails applications on a Windows box?

I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.

Resources