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
[[email protected] ~]$  

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
[[email protected] ~]$

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
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 (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
[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
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Build a development environment for Docker + Rails6 + Postgresql
Build a WordPress development environment quickly with Docker
[Win10] Build a JSF development environment with NetBeans
[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 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
Deploy to Ruby on Rails Elastic beanstalk (Environment construction)
How to build Java development environment with VS Code
Ruby ① Build a Windows environment
Try to build a Java development environment using Docker
Docker command to create Rails project with a single blow in environment without Ruby
I tried to create a java8 development environment with Chocolatey
I made a development environment with rails6 + docker + postgreSQL + Materialize.
[Ruby on Rails] Add a column with a foreign key constraint
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
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
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
Ruby on Rails 6.0 environment construction memo
Build a XAMPP environment on Ubuntu
Build jooby development environment with Eclipse
Build Unity development environment on docker
Build a local development environment for Rails tutorials with Docker-Introduce Bootstrap and Font Awesome with Webpack-
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
I tried to build an http2 development environment with Eclipse + Tomcat
I tried to create a Spring MVC development environment on Mac
How to install Pry after building Rails development environment with Docker
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
Build a development environment for Django + MySQL + nginx with Docker Compose
[Introduction] Build a virtual environment of Vagrant + VirtualBox on Window10 [Environment construction]
(Ruby on Rails6) Create a function to edit the posted content