How I turn an average desktop PC into server for hosting a website using Ruby on Rails? - ruby-on-rails

What is the best way to turn an average desktop PC into server for hosting a website using Ruby on Rails?
I am open to changing operating systems, buying parts if I need to, using whatever Database People recommend and any software.
Here are the approximate details of the computer:
The computer is an HP Desktop with 1.86GHz Duo Core CPU. Intel chipset.
1GB Ram, 200GB Hard Drive
Runs on Windows XP
FYI, This is not a commercial project and this is not about saving money. I just want to pick up some new skills and I think it would be fun.
Thanks,
Jeremy

Just a suggestion, you could just use http://www.slicehost.com. You can buy a virtual machine with 256MB for $20/month but you build the machine from scratch after loading a base Linux distribution like Ubuntu. There are excellent instructions there on how set up your OS to do whatever you want to do.
If you really want to run a server on that machine you have though, thus saving $20/month, I would recommend installing some form of Linux. I would suggest Debian or Ubuntu. If you want to learn a bit more about some Linux fundamentals like building a kernel and tweaking .conf files (could be useful at some point) try a distribution like Gentoo. Basically download the ISO and boot it up.
If you just want to play with Ruby on Rails on that box, of course, just go to http://localhost. Furthermore, you don't even need to set up apache if you are just playing around... just use the web server built in to Rails. To be able to access that machine from anywhere in the world, if you have a static IP, get a domain name and point to that IP. If your IP is dynamic then use dyndns.org to get a dynamic host name. You can usually configure most routers to update sites like dyndns.org with your up-to-date dynamic IP.

While you can setup Rails on Windows, most people tend to use some flavor of Linux or BSD. The hardware you have should be more than enough for what you're asking it to do.
There are many tutorials on how to install the software you'll need. A typical stack would be Ruby, the Rails gem, MySQL (with ruby bindings and gem), Apache, and Passenger.
Slicehost, for example, has a good setup tutorial for Ubuntu. Depending on how much you want to learn about system administration, you can use a package manager to install (apt-get or aptitude on Ubuntu, for example), or compile from source.
Rails' default configuration is set up to use SQLite as the database, which requires basically no administration. If you make your site public and are getting more than a handful of users, MySQL or PostgreSQL is the next step.

Note that XP by design is limited to 10 concurrent open connections at once. This is so people need to buy the higher priced Server editions of Microsoft OSes for production servers. However, it should be fine if all you want to do is experiment.
First, you need an IP willing to give you a static IP (or get a dynamic DNS solution). DNS is what maps a URL to a IP address and a constantly changing IP address is going to give you a bunch of headaches.
Next, you need to purchase a domain and have it point to your IP. If your machine is behind a router, you need to go into the NAT settings in the router and have it forward port 80 to your machine.
Finally, you need to install some kind of web server on your local machine. If you want to work with rails, I recommend installing InstantRails which comes with the Apache web server and MySQL by default.
Once this is done, spin up InstantRails, load up a rails project and then visit your domain to see if it all works.

EngineYard, one of the bigger Rails-based hosts, offers a VMWare image of their deployment platform that you can download from http://express.engineyard.com/
It will work the the free VMWare Player http://www.vmware.com/products/player/ which runs on WinXP.
This arrangement, which I've done several times for small and internal projects, gives you a full-featured Rails server with prebuilt deployment recipes (using the engineyard-eycap gem).
Download VMWare player
Download EngineYard Express
Boot your new server in VMWare Player and go to town.
The only hardware suggestion I'd make is to add more memory -- the VMWare image used 640mb by default and performs better with more, though it doesn't sound like performance is your concern.
What's particularly nice about this solution is that you can move to a commercial option (EngineYard Solo on Amazon EC2 or the full EngineYard offering) or roll your own with Slicehost, etc once you're comfortable with Rails. But this solution puts you in charge of the development side of things without needing to waste time on the server side.

On windows, first install xampp.
http://www.apachefriends.org/en/xampp-windows.html (download and install: Installer 39 MB)
This will install apache, php and mysql database.
Then you need to install ruby: http://peri.me/?p=73
By the end, you be running ruby on your home pc.
If you want someone other than you to access the content on the server, you would need to somehow tweek your router or computer's setting to allow access.

I like Shalmanese's answer but I would add that you need a firewall. If you have no hardware one, you need to configure your iptables in linux, which is lots of fun by itself :) Especially if you have to rebuild kernel first to have it work.

you can find a lot of tutorials to setup "perfect servers" on various distros on how to forge Just search for "perfect server" on their site and you are good to go :)

Public IP Address and a sort of Linux with Apache (Passenger or mongrel).

You can run a Linux host in a virtual machine within your Windows desktop, using free software like Sun's VirtualBox or Microsoft's Virtual PC. I do this all the time to run development Linux servers for my environment, but it would work equally well for "quasi-production" hosts that you are just playing with.

Related

How to deploy a rails application on Windows PC (windows 7 / windows 8)?

I have built a rails app which is used as a standalone enterprise application. The application needs to run on Windows desktops (entire user base runs Windows machines). I am able to run it quite successfully on an Ubuntu machine but it's not something customers will prefer to run.
Since deploying on a windows machine is quite messy AFAIK. I would like deploy it on Windows using a virtual machine (VirtualBox).
Requirements would be -
Application installation on Windows 7 / Windows 8.
User should be able to access rails server by browser running on his/her system via localhost or any other IP address.
Application should auto-start when user reboots the machine.
Ideally user should be able to download and install the software on his/her machine by himself/herself.
I am working to make this work but would like to know the feasibility of this solution. Would like to if I am getting the concepts wrongs or if there is something which is simply not possible or is not making any sense.
Take a look at Vagrant, which is a highly scriptable VM host. You can then generate batch files to automatically start the VM on boot.
To deploy new code, you'll just want to provide them with a new VM image they can copy into your app directory.
That said, I agree with other comments that this might not be the right platform for your use case. The main reason for building web apps is so that many clients can use your app over the web using just one set of servers. Deploying a web server to each client seems like it's defeating that advantage.

How to set-up vicidial in local system?

I want to set-up vicidial in my local computer server any information or a document for that?
I googled but I can't find exact resource.
I googled below links.
Link 1
Link 2
Thanks in advance.
Vicidial is an Open Source Predictive AutoDialer based on Asterisk with PHP/MySQL/Perl coding.
Installation of Vicidial is only viable on a Linux machine.
There are several locations with Scratch Install instructions for Ubuntu and CentOS. In fact, the Vicidial Wiki has a list of a few of them: http://wiki.vicidial.org/index.php/VICI:Installation
Most are quite old except for the Goautodial.com which has instructions for CentOS installation by adding the goautodial repositories and then just upgrading the OS to get all the necessary packages.
If you're not using CentOS or Ubuntu and none of those instructions work for your purpose, beware that Vicidial installation is not easy. It is MUCH better to dedicate a machine to the purpose by installing from Vicibox.com's .iso image which will wipe the computer clean. The installation becomes easy and then you need only argue with configuration.
If you can not dedicate a machine to this purpose, you should take the earlier suggestion of a Virtual server (vSphere or Virtualbox both work for Vicibox.com's .iso installer), but beware that you'll only be able to have one or two agents on the virtual dialer at the most. Luckily, if you do get the virtual vicidial working, it is possible to backup the virtual server's database and install it on a hardware based server later to bring everything with you without having to do it all over.

How to make a struts2 project an executable Application

I have developed a Struts2 Project using Apache server and MySQL database.
Is it possible to make this application an executable application so that i do not need to give JDK, Apache and MySQL separately to the user. The installer could install all these 3 itself.
Also can i make this so that only a single user can use this application. How Please Tell.
Usually a Web Application has a central server (with at least: a Java Virtual Machine, a Web Server / Application Server, a Database, and the Web Application contanining the Java code), and all the client computers use their browsers to connect to it.
The kind of application that seems to arise from your description is a monolitic one, like a GUI App made in Swing or in Visual Basic; you install it in the clients, and each one has a copy of each component. If you install it 20 times, you will have 20 database, 20 copies of the files, etc...
Even in client-server applications, with centralized database and distributed code, the problems were always client-related; you can't know if the system were you are automatically installing a database, an JDK etc... already has that software, maybe in other versions, or has the environment variables messed up etc. When you need to update the software, or to tune up the system, you need to be physically log to that pc, remotely or by person. This are some of the reasons that led to the choice of preferring Web Applications to distributed applications.
If you need to craft a "package" of your application to be installed in one click by a dumb user (let's say, a portable version of your application, to let your PM perform some Demo in remote locations, or to give it to the big boss to let him see it), you should really evaluate the possibility of creating a Virtual Machine.
A Virtual Machine is a big file (on a hard disk, or read by an USB key, etc) that, once mounted by a Virtualization Software (usually the same software that created the Virtual Machine), will run an entire new OS inside a window of your guest OS.
The leading software to do this is VMWare (the Player is free and cross-platform), alternatively you can use VirtualBox.
Then, you need to
download VMWare Player
download the ISO of your favourite Linux distribution (I hope you don't use Windows as server)
create a, let's say, 10GB partition for your Linux distribution with VMWare Player, and mount it
plug the ISO with something like (the free edition of) Daemon Tools
install the Linux distribution
install and configure all the software you need there (Apache, MySQL, your favourite browsers, etc; JVM usually is already there)
install your web application
Then you will have a physical file with a complete Linux OS inside, with all the needed software already tuned up: just distribute this file to Windows, Mac or Linux users, they will only need the VMWare Player installed to run your file and access (their copy of) your application inside the Linux OS.

I need a real UNIX RoR development environment

From the beginning, I am a Windows master. I started with MS-DOS. I put up Windows 2.1 and every Windows since. I have 10 different Windows boxes running in my house right now, from Windows 7 Ultimate to varied flavors of Windows Servers. I haven't done Windows 8 and don't want to go there.
I have UNIX experience with both servers and varied software, but it hasn't been my preferred environment. However, I guess I am converting. I've tried to pretend to run UNIX under Windows using Cygwin and MSYS. My purpose is to build a development environment. Both have failed me. I have spent more time trying to fix a series of technical issues than I have developing. That is unacceptable.
My Ruby on Rails development environment is by far my highest current priority. I have websites to build, right now.
At this point, I have two options. One is to find a UNIX development environment in a cloud. The other is to convert one of my many machines to a true UNIX system. So, I need advice. I don't really want to build and babysit a system. The idea of a cloud-based development environment is very interesting, with the caveat that I don't chase it down another rat hole like I have with Cygwin and MSYS.
Here are the questions. Is there a solid cloud-based Ruby on Rails friendly development environment out there? Failing that, should I put up an Ubuntu-based system. If I go there, do I convert a workstation or a server?
Thanks...
I highly recommend Vagrant. I use this to do development on my Windows systems.
As you found out, Windows is terrible for RoR development. Your best option would be to use a VM like VirtualBox to run a Linux/Unix instance. There are other VM options, but VirtualBox is free.
Failing that, just convert once of your boxes to Linux/Unix. For development it does not matter one bit if it is a workstation or a server.
Mac OSX
The unofficial standard for RoR production is Linux, but for development it is Mac OSX. There has been a big migration of developers to the Apple platform that has been going on for many years now.
It gives you the best of both worlds: it is Unix underneath but it's also a commercial platform, a polished UI, and an available software ecosystem.
Yes, it's expensive, but people should ask themselves, why are people willing to pay so much? If you can afford 10 boxes for Windows, how about finding $ for one Mac? Then, you will have not just a workable RoR environment, but the best.
Or go VM
But if you don't take that advice, you may want to install a Hypervisor like Xen or XenServer for free, and then you can run both Windows and Linux on the same machine. This is slightly different than running a VM under Windows.
Externally, I have received a recommendation for EngineYard.com as an outstanding RoR environment and will ultimately consider it as my primary development/migration/production environment.
I have a working Debian system now and am building it out as a local RoR environment. It just seems to be right for a serious RoR development environment. I will go there as soon as it is fully built out because RoR is just meant for UNIX.
However, at least temporarily, I have found that RubyStack is a seriously usable Windows RoR development environment. It is 100% usable as a standalone system that doesn't require UNIX-style environments shoehorned onto Windows. Trying to run UNIX on Windows was a constant source of frustration, so this meets my immediate needs.

Most stable (headache free) development environment for Ruby on Rails?

Would some of the more advanced rails developers please share what they have found to be the most productive combination of OS, IDE, etc. (i.e. the set-up that gives the least of amount of compatibility issues, headaches)? Also, what is the most commonly used setup?
I presume the common setup is common because it is thought to be the best compromise between all the options.
And that common setup is:
Mac OS X
TextMate
rvm
There's a lot of nuance to your question, for example you'd probably want to take into account what you already have, what your appetite is for spending money, etc. This is before even coming to the minefield of personal preference. :)
Here's a starter list:
Operating System
In my experience on both, Mac > PC for Rails programming because it creates fewer unforeseen/annoying problems.
IDE
Depends on how 'rich' you like your environment to be. Some people who like light environments simply use Notepad++; others use richer options like TextMate (Mac only) or RubyMine.
General Set up
Rails 3.1, MySQL
Local Server
Webrick and Mongrel are fairly popular.
Hosting
Heroku is extremely popular for Rails apps. It's free for low traffic and they're beautifully designed for Rails. If you want to avoid the server reloading problem (webpages take a while to load if no one has requested them in a while), you can set up NewRelic or Pingdom to ping the app and keep it active.
Performance Monitoring
NewRelic
I moved from Windows for Rails 3 to a Ubuntu 11 virtual machine running on Windows via VMWare player.
I'm using Gedit along with GMate (source here) to make Gedit more similar to TextMate for Rails Development.
I've found the setup to be way faster running on the virtual machine than it was on Windows directly. It took some time to get set up but once done, I just transfer the vm image from machine to machine. The setup was all free too (besides my laptop and the copy of Windows 7 on it).
The most common development environment I suspect you'll find among the Rails illuminati is probably:
Mac OS X (though some use Linux)
various Ruby versions/gemsets in RVM
TextMate or MacVim as the IDE (gvim or vim for the Linux folk, usually, though some prefer Emacs)
SQLite or MySQL for development database
Webrick, Mongrel, Thin, or flavour-of-the-day lightweight local webserver

Resources