How to Install Ruby on Rails on a Windows VPS or Dedicated Server

How to Install Ruby on Rails on a Windows VPS or Dedicated Server

Ruby on Rails is a robust application framework that provides impressive features for creating incredible database-backed web applications using the Model-View-Controller pattern. It provides the default configurations for web services, web pages, and database while facilitating the use of CSS, HTML, and JavaScript for display and web standards for data transfer.

Ruby on Rails installation is simple and easy, and this guide is compiled to make it straightforward. The tutorial eliminates the need to install an alternative testing framework, a fancy database, or anything of that nature. It’s a bare-bones, instructive article that will help you learn how to install Ruby on Rails on a windows device.

Ready? Let us get started!

Special note: this article is specific to VPS or Dedicated server hosting using Windows OS. Use HostAdvice’s expert and user reviews to find the best Windows hosting, best VPS hosting and best dedicated server hosting services.

Step 1:
Download and install Ruby

The first step when installing Ruby on Rails on Windows is downloading and installing Ruby since it’s the base. Visit: http://rubyinstaller.org/ and download the installer. This Ruby installer streamlines the setting up of Ruby on your Windows device.

Select the right installer based on the type of your Operating System (OS); 32 or 64-bit.

Next, we’ll install the Ruby Installer (version 1.9.3 in this case), you will need to check “add Ruby Executable to your path” before clicking the install button. This will add Ruby to your PATH. Once you are done with the installation, verify the installation of Ruby in C:\ruby193 and confirm it’s added to the specified PATH environment variable.

A new Windows interface titled: “start command prompt with Ruby,” will be created on the start page.

Click on the emerging command prompt (CMD) to create a folder at C:\Sites. This folder will be a unified location for all your Ruby apps.  Open the CMD on C:\Sites and type ruby –v to confirm the type of the Ruby installed.

Next, verify the Gem version installed on the CMD type using the command below:

gem -v

If need be you can bring up-to-date the gems by running the following line:

$ gem update - - system

Step 2:
Install rails gem

Rails is one of Ruby gems and can be found on RubyGems.org. Search for “rails” to find the latest version:

Next, install the Rails using RubyGems. Type “gem install rails” make sure you spell rails as found on rubygem.org. Sometimes the command may fail and prompt the following error:

This is because the right Devkit is not installed. For this reason, we install the devkit,

Download and install the Ruby DevKit

Click on the link http://rubyinstaller.org/add-ons/devkit/ to get the DevKit. If you are installing the latest type of Ruby starting with 2.4.0, use the MSYS2 toolchain as your DevKit. On the other hand, Ruby+DevKit version, the DevKit is a selectable component; you need no additional download.

However, the Ruby version without DevKit allows you to install the MSYS2 DevKit as a separate component by running ridk install. The MYSYS2 is vital in building native C/C++ addons for Ruby. In addition, it enables you to download and use the multiple Open Source Libraries that Ruby Gems depend on.

Based on the type of your Ruby, Download the right DevKit as follows:

Once you download the DevKit, extract the files and store them in C:\Ruby193\Devkit. Open the DevKit files, first, run the ruby dk.rb/init then ruby dk.rb install.  This will enable Ruby to recognize the DevKit.

Once the Devkit is successfully installed, trace the C:\Sites and use the command below again:

$Gem install rails

It should work but might take some minutes before you notice any progress. In addition, the gem has a lot to do and may take longer to complete the installation. Once the installation is completed, run “gem list” to see the bunch of gems installed. The list should include gems like Rails, ActiveRecord, actionpack, and more.

Step 3:
Configure the Rails database

Rails application cannot operate without a database. For this reason, you must install an appropriate database; you can work with MySQL or the SQLite database. SQLite3 is the default Rails database and is the simplest to set up.

To install SQLite database run the command

Gem install sqlite3

We’ll use the SQLite3 as our default database.

However, if you want to utilize MySQL as the Rails database , run the following command:

$ gem install mysql
#in case of problem
$gem install mysql -platform=ruby - -with -mysql -dir=c:\mysql

The directory path can be modified based on your MySQL installation. You need to download the C connector, follow this link: https://dev.mysql.com/downloads/file/?id=377977. Once it’s successfully downloaded, extract the code /lib/libmysql.dll into your C:\rubybin folder.

Step 4:
Install git.

The git. Makes it easy to track code and version control. The Windows version of the git. Can be downloaded from here: http://git-scm.com/downloads

Step 5:
Create Rails app

We’ll now try to develop an original Rails app; the best way is to create the app in the C:\Sites folder. Go to the command prompt, and locate the C:\Sites folder. Let’s develop a new app called “firstruby,” at the command prompt, type:

$Rails new firstruby

This will automatically generate the firstruby application which will be configured to utilize the SQLite database. However, to set the application to utilize MySQL database, you can run the following command:

$Rails new firstruby -d mysql

The part –d mysql informs the Rails that you want to utilize MySQL as your database for the new application. Confirm the new application is created in the folder C:\Sites. The new application can be deleted, by simply deleting the firstruby folder in C:\Sites.

Also, insides the created Rails application there is a public folder. This folder is “public” because it’s the one that is displayed to the user/public through the web server. It contains the web assets and codes like JavaScript, CSS, and images.

Step 6:
Start a webrick server

For the web application to be displayed to viewers, you must start up your web server. Here we should configure the web server to work with the new app. In our case, we’ll launch the server (WEBrick ) that is integrated with Rails.

Inside the firstruby folder, type:

rails server

Check the box for “Private networks…..” and allow the access.

Step 7:
View the app in the browser

The server started on the port 3000, which means we can browse http://yourlocalhost:3000. This will direct us to the Rails home/welcome page

Click on “about your application’s environment” to the app’s specifications

Step 8:
Stop the server

It’s wise always to stop the server when not modifying on your app. To stop WEBrick on the development environment use Ctrl-C. When requested to terminate the job type Y. That’s all.

Conclusion

By now Ruby on Rails is perfectly installed on your Windows device. Next, you will be tasked with configuring and incorporating a code into the application. We hope this guide was helpful!

 

Check out the top 3 Windows hosting services:

Ultahost
£1.88 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8
Kamatera
£3.01 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Verpex Hosting
£0.44 /mo
Starting price
Visit Verpex Hosting
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.5
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.0

How to Create a Simple Web Server Using Node.js and Express

This tutorial shows you how to create a simple web server using Node.JS and Expr
less than a minute
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to install Django on a CentOS 7 VPS or Dedicated Server

When building a website, similar components are required, and you do not have to
less than a minute
Mark Armistead
Mark Armistead
Author

Use Python to Automate Routine Tasks on Your VPS or Dedicated Server

Here we'll use basic knowledge of Python to teach you how to leverage the extrao
less than a minute
Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan
Hosting Expert

How to Connect to a Server by Using SSH on Linux and Mac

Most servers in the world are run on Linux servers. They’re dependable, afford
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top