Setting up Rails6 on Windows10

Ruby on Rails is a web development framework that was first introduced in 1999. Despite it’s “age”, it’s still a popular choice for developing web applications.

In this small tutorial, we’re going to go through the steps involved in setting up Rails6 on Windows10.

There are a few Rails installer type of projects available, but I’ve found that these mostly don’t work anymore despite coming up near the top of any search in google. If you’ve come across them already and they work for you, then fantastic!

I’m not throwing shade at any of these projects, by the way, merely trying to communicate to others who might be hunting around for the same information and coming across the same resources (and therefore experiencing the same frustration).

  • RailsInstaller - the Windows download this project offers is for Ruby 2.3 which is quite outdated. As of this writing, I’m using Ruby 2.6.5. I recommend you skip this one.
  • Install Rails - this is another fine effort, but still referencing the older Ruby download from railsinstaller. I also recommend you skipping this one.
  • Go Rails - this is a high quality Ruby on Rails installation guide, but its relying on the use of the Linux Subsystem for Windows 10 (eg. WSL). With the amount of work put into WSL2 by Microsoft and other parties, it’s definitely turning into a great option for working on Rails projects on Windows.

using Chocolatey to install Ruby on Rails on Windows 10

A popular Windows 10 package manager is Chocolatey. It can handle downloading and setting up Ruby for us.

  • Head to chocolatey.org for a glance through the site
  • You need to install Chocolatey through PowerShell
  • Type Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process
  • When that completes, paste the following snippet into the shell
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    
  • Just to be sure your system PATH is updated, close the PowerShell console

install Ruby via Chocolatey

  • You’ll have to install Ruby with Administrator privileges
  • Open a command prompt window using Run as Administrator
  • Type choco install ruby in the console
  • Once the install finishes, close the command prompt window. We no longer need Administrator level AND we want to make sure our system PATH has been updated

using Scoop to install Ruby on Rails on Windows 10

Another recent popular management tool on Windows 10 is Scoop. I’ve been trying it out personally for a while, and I prefer it to Chocolatey.

  • Head to the Scoop website and take a quick boo at the website
  • You need to install Scoop through PowerShell, so open a PS terminal
  • Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • When that completes, paste the following snippet into the shell
    Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
    
  • Just to be sure your system PATH is updated, close the PowerShell console

install ruby via scoop

Scoop lingo uses the concepts of “apps” and “buckets”. An “app” is a single application or program to install. Whereas a “bucket” is a collection (or loose collection) of apps. To be a bit more accurate, a bucket contains a collection or grouping of app manifests - that is, the info needed by scoop to install a particular app.

  • scoop bucket add versions add the versions bucket (handy for needing a specific version of some apps like Ruby or Java)
  • scoop bucket add extras add the extras bucket
  • scoop search ruby will come up with a list of available ruby versions
  • scoop install ruby will use the latest version
  • scoop install ruby ruby24 will install ruby (2.4.10-1) for example if you need a specific version
  • that’s it

install ridk

  • Open a command shell
  • Type ridk install
  • When prompted, just hit Enter (we want the defaults)
  • The installation will take a little bit of time
  • You’ll be prompted for any further actions, again just hit Enter to exit

install rails 6

  • We’re finally there! We can install Rails6 now!
  • Open a command shell
  • Type gem install rails
  • Tada!

Conclusion

There are several popular resource guides available for installing Ruby on Rails on Windows 10, but they are either quite outdated, or may not be a good “fit” with your system setup.

To try and help others coming across the same batch of resources and hitting the same speed bumps, I put together this small guide to give you a hand. Hopefully it does the job for you without issue(s).

If you found this tutorial helpful, please share it!

Installing Rails6 on Raspberry Pi

Ruby on Rails is a web development framework that was first introduced in 1999. Despite it’s “age”, it’s still a popular choice for developing web applications.

In this tutorial, I’m going to explain how to install Ruby on Rails 6 on Raspberry Pi. I’m going to assume that you have Raspbian installed on your Raspberry Pi.

Installing the Essentials

You should begin by installing the prerequisites, to prepare for the installation of Rails. Type the following command into the Terminal window.

sudo apt-get update && sudo apt-get install -y git curl zlib1g-dev subversion

While you’re already getting the required packages, you’ll need to retrieve the SSL package, SQL database package, and a few more.

sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev
sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3
sudo apt-get install -y libxml2-dev libxslt-dev
sudo apt-get install -y autoconf automake libtool bison

Open up the RVM, straight from its repository on GitHub with the help of curl.

curl -L get.rvm.io | bash -s stable --rails

Once you’ve successfully installed the required packages, and have opened up the RVM, it’s recommended that you run a local script, just so that you can enable Ruby.

source ~/.rvm/scripts/rvm

Testing the Installations

No “weird” error messages during this procedure is likely a good sign. You can test your new Ruby support by typing the following command.

ruby -v

You should see a message confirming which version of Ruby is installed, when it was produced, and what it’s using in order to work correctly.

You can also test for Rails by typing in the following command.

rails -v

Conclusion

Hopefully this was a simple walkthrough to show you how to setup the latest version of the Ruby on Rails web development framework on the Raspberry Pi. Rails is a very popular framework, so it’s great to also have that option on the Raspberry Pi!

Installing Nginx on Raspberry Pi

NGINX (pronounced engine x) is a popular lightweight web server application you can install on the Raspberry Pi to allow it to serve web content.

Like Apache, NGINX can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP, .net core, JavaScript or any other popular web development programming language.

In this tutorial we will investigate how we can use the Raspberry Pi to become a lightweight web server, by installing Nginx on it.

Installing the Essentials

In an open Terminal session window, type the following command to install Nginx:

sudo apt-get update
sudo apt-get install nginx

Once the installation has completed, you can start the Nginx web service with:

sudo /etc/init.d/nginx start

You can now test that the Nginx web server is working as expected by starting up a local Chromium browser instance on your Raspberry Pi.

You should see the default nginx test page when you open http://localhost

Installing PHP

Now that Nginx is running, it’s just another trivial package install to enable PHP support! In an open Terminal session window, just type the following to install the latest php-fpm connector.

sudo apt-get install php-fpm

Like most web servers, Nginx allows for a set of “default” supported web documents. In other words, when you make a browser request to the root of a folder on your web server without any specific page, eg. https://yoursite.com/ vs. https://yoursite.com/page1.html, Nginx will check it’s list of supported default documents. If your folder has such a named default document file, then it will return that automatically to the browser.

Let’s add support for PHP.

sudo nano /etc/nginx/sites-enabled/default

Find the following line:

index index.html index.htm;

and add index.php to the list:

index index.php index.html index.htm;

Then look for a section which is commented out (with #)

Then update

Reload Nginx to pick up the recent configuration changes:

sudo /etc/init.d/nginx reload

Create a test default PHP page

To help test (and demonstrate) our newly added PHP support, let’s create a default PHP page.

cd /var/www/html/
sudo mv index.nginx-debian.html index.php

Now open the index.php file with nano

sudo nano index.php

After the <body> tag in the page, but before the closing </body> tag, add the following:

<body>
  <?php echo phpinfo(); ?>
</body>

Save and close up nano. Now open Chromium browser and navigate to http://localhost. You should see the familiar PHP info output.

Conclusion

Hopefully this was a simple walkthrough to show you how to setup the latest version of Nginx on the Raspberry Pi. As an additional bonus, I also included some easy steps to enable a fast and lightweight PHP connector for Nginx.