macOS 10.15.4
Install Vagrant from your home page.
https://www.vagrantup.comFirst, 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"
Run the command below and wait a moment ...
terminal
$ vagrant up
Execute the following command to log in.
terminal
$ vagrant ssh
[vagrant@localhost ~]$
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
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.
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.
Execute the following command to install Bundler.
terminal
$ gem install bundler
$ rbenv rehash
$ bundle -v
Bundler version 2.1.4
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
Execute the following command to access the following address.
terminal
$ ./bin/rails s -b 0.0.0.0
http://192.168.33.10:3000/
This is the end of the procedure ^ _ ^
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 ~]$
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