rails on windows with vagrant
19 July 2017Some notes on setting up Rails on Windows with a Vagrant Ubuntu box.
Step 1: Installing Vagrant
-
Install VirtualBox. I'm using version
5.1.24. -
Install Vagrant. (Version
1.9.7.) -
Test it's working with
vagrant -v. -
Add the box:
vagrant box add ubuntu/xenial64. -
Create the project folder,
cdinto it andvagrant init. -
Add
hashicorp/precise64to theconfig.vm.boxinVagrantfile.
Step 2: Installing Ruby
This entire section is taken from this guide.
-
sudo apt-get updateandsudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs.
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.4.0
rbenv global 2.4.0
ruby -vI end up with Ruby version 2.4.0.
gem install bundlerandrbenv rehash.
Step 3: Installing Rails
-
gem install railsandrbenv rehash. Gets me Rails version5.1.2. -
Add this line to
Vagrantfile:config.vm.network "forwarded_port", guest: 3000, host: 3000. -
vagrant upandvagrant ssh. -
rails new myApp,cd myApp. -
Start the server with
rails s -b 0.0.0.0. -
In Windows go to
localhost:3000.