Steps to build a Ruby on Rails development environment with Vagrant

environment

macOS 10.15.4

Install Vagrant

Install Vagrant from your home page.

スクリーンショット 2020-07-12 16.09.53.png https://www.vagrantup.com

Install Cent OS

First, check if Vagrant is installed.

terminal


$ vagrant -v
Vagrant 2.2.9

Create a directory and move it.

terminal


$ mkdir -p vagrant/centos7
$ cd vagrant
$ cd centos7

Execute the following command in the moved directory.

terminal


$ vagrant init centos/7

After the installation is complete, open an editor and uncomment the line below.

Vagrantfile


# config.vm.network "private_network", ip: "192.168.33.10"
スクリーンショット 2020-07-12 16.22.25.png

Run the command below and wait a moment ...

terminal


$ vagrant up

Log in to CentOS

Execute the following command to log in.

terminal


$ vagrant ssh
[vagrant@localhost ~]$  

Install rbenv

Prepare the yum package.

terminal


$ sudo yum install -y git gcc openssl-devel readline-devel zlib-devel sqlite-devel gcc-c++ libicu-devel cmake vim

Install rbenv.

terminal


$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv    
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

Check if the installation is complete.

terminal


$ rbenv --version
rbenv 1.1.2-30-gc879cb0

Added ruby-build plugin

Execute the following command to add the ruby-build plugin.

terminal


$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Install Ruby

Install Ruby.

terminal


$ rbenv install 2.7.1
$ rbenv global 2.7.1
$ rbenv rehash
$ ruby -v 

After confirming that the installation is complete, proceed to the next step.

Install Bundler

Execute the following command to install Bundler.

terminal


$ gem install bundler
$ rbenv rehash
$ bundle -v
Bundler version 2.1.4

Install Ruby on Rails

Create and move the directory for installation.

terminal


$ mkdir -p app/memo_app
$ cd app
$ cd memo_app

Then run the command to install.

terminal


$ bundle init
$ sed -i 's/# gem "rails"/gem "rails", "~> 5.1.0"/g' Gemfile
$ bundle install --path vendor/bundler
$ bundle exec rails new .
$ sed -i "s/# gem 'therubyracer'/gem 'therubyracer'/g" Gemfile
$ bundle install

Start the server

Execute the following command to access the following address.

terminal


$ ./bin/rails s -b 0.0.0.0

http://192.168.33.10:3000/

スクリーンショット 2020-07-12 12.29.09.png

This is the end of the procedure ^ _ ^

(Supplement) About shutdown and login / logout

I will also explain shutdown and login / logout because you will need it when you close it once or reopen it.

** Log out **

terminal


#Command for logging out of CentOS
$ exit
 
#Command to shut down CentOS
$ vagrant halt
   

** Login **

terminal


#Commands for logging in to Cent OS
$ vagrant up
   
$ vagrant ssh
[vagrant@localhost ~]$

Procedure to enable you to create an application with a high-performance editor (VS Code) even in the Vagrant development environment

A virtual environment of Vagrant has been built, but please also refer to it because it explains how to connect it so that it can be created and edited even with a high-performance editor (VSCode) ^ _ ^

https://qiita.com/chisaki0606/items/982f296389ffcb850994

Recommended Posts

Steps to build a Ruby on Rails development environment with Vagrant
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Build a Ruby on Rails development environment on AWS Cloud9
Build a development environment to create Ruby on Jets + React apps with Docker
Build a development environment where Ruby on Rails breakpoints work on Windows
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Minimal steps to set up a Ruby environment with rbenv on Ubuntu 20.04
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
How to build Rails, Postgres, ElasticSearch development environment with Docker
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Build a PureScript development environment with Docker
[Ruby] Building a Ruby development environment on Ubuntu
Build a Java development environment on Mac
Build a Wordpress development environment with Docker
How to build Rails 6 environment with Docker
Ruby on Rails --From environment construction to simple application development on WSL2
I want to add a browsing function with ruby on rails
Create a development environment for Ruby 3.0.0 and Rails 6.1.0 on Ubuntu 20.04.1 LTS
Build a development environment for Docker + Rails6 + Postgresql
Build a WordPress development environment quickly with Docker
[Win10] Build a JSF development environment with NetBeans
Ruby on Rails development environment construction on M1 Mac
[Rails] How to build an environment with Docker
How to build a Pytorch environment on Ubuntu
I made a portfolio with Ruby On Rails
Build a Java development environment with VS Code
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
I tried to build a Firebase application development environment with Docker in 2020
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
Memo to build a Servlet environment on AWS EC2
Build Java development environment with VS Code on Mac
[Introduction] Try to create a Ruby on Rails application
[Environment construction] Ruby on Rails 5.2 system development environment construction [within 1 hour]
Deploy to Ruby on Rails Elastic beanstalk (Environment construction)
How to build Java development environment with VS Code
Ruby on Rails environment construction using VirtualBox, Vagrant, cyberduck
Ruby ① Build a Windows environment
[Environment construction] Build a Java development environment with VS Code!
Try to build a Java development environment using Docker
Docker command to create Rails project with a single blow in environment without Ruby
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
I made a development environment with rails6 + docker + postgreSQL + Materialize.
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
A series of steps to create portfolio deliverables with Rails
How to display a graph in Ruby on Rails (LazyHighChart)
A memo to build Jitsi Meet on Azure with docker-compose
Build a CentOS 8 virtual environment on your Mac with VirtualBox
Build a Node-RED environment with Docker to move and understand
Apply CSS to a specific View in Ruby on Rails
I tried to create a padrino development environment with Docker
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
How to use Ruby on Rails
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose