Install #Vagrant Install Vagrant from the home page.
Cent OS installed
First, check if Vagrant is installed.
$ vagrant -v Vagrant 2.2.9
Create a directory and move it.
$ mkdir -p vagrant/centos7 $ cd vagrant $ cd centos7
Execute the following command in the moved directory.
$ vagrant init centos/7
After the installation is complete, open the editor and uncomment the following line.
# config.vm.network "private_network", ip: "192.168.33.10"
Run the command below and wait a moment…
$ vagrant up
Log in to CentOS
Execute the following command to log in.
$ vagrant ssh [vagrant@localhost ~]$
Prepare the yum package.
$ sudo yum install -y git gcc openssl-devel readline-devel zlib-devel sqlite-devel gcc-c++ libicu-devel cmake vim
$ 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 completed.
$ rbenv --version rbenv 1.1.2-30-gc879cb0
add ruby-build plugin
Execute the following command to add the ruby-build plugin.
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- As an aside, the version was 2.4 when I referred to someone else’s site. However, Rails 5 or higher and the current mainstream Rails version require 2.5 or higher, so be careful about specifying the version.
$ rbenv install 2.7.1 $ rbenv global 2.7.1 $ rbenv rehash $ ruby -v
If you can confirm the completion of installation, proceed to the next step.
Execute the following command to install Bundler.
$ gem install bundler $ rbenv rehash $ bundle -v Bundler version 2.1.4
Install Ruby on Rails
Create and move directories for installation.
$ mkdir -p app/memo_app $ cd app $ cd memo_app
Then run the command to install.
$ 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
Execute the following command to access the address below.
$ ./bin/rails s -b 0.0.0.0
This ends the procedure ^_^
(Supplement) Shutdown and login/logout
I’ll also explain shutdown and login/logout, as you’ll need it when you close it or open it again.
# Command to log out from CentOS $ exit # Command to shut down CentOS $ vagrant halt
# Command to log in to Cent OS $ vagrant up $ vagrant ssh [vagrant@localhost ~]$
Vagrant development environment procedure to create an app with a high-performance editor (VS Code)
A virtual environment of Vagrant has been built, but I will explain how to connect it so that you can also create and edit it with a high-performance editor (VS Code), so please also see ^_^