How-To run a first Vagrant project on macOS in the Terminal
1 min readJul 19, 2020
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" #Install Homebrew
- Install Virtualbox with a Terminal
brew info virtualbox #Check a version of the VirtualBox
brew install virtualbox #Install the lates version of the VirtualBox
brew install vagrant #Install the lates version of the Vagrant
- Create a working directory
mkdir ~/vagrant #Create a folder named by vagrant
- Create a folder for project <example>
mkdir ~/vagrant/ubuntu_server #Create a folder named by ubuntu_server in the directory vagrant
- Create Vagrantfile
touch ~/vagrant/ubuntu_server/Vagrantfile #create Vagrantfile in the working directory
- Open Vagrantfile for edit
nano ~/vagrant/ubuntu_server/Vagrantfile #Open Vagrantfile
- Configuration for you Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
config.vm.provision 'shell', inline: <<-SHELL
echo 'ubuntu:ubuntu' | sudo chpasswd
SHELL
end
- Run Vagrant config file on your working directory
cd ~/vagrant/ubuntu_server #Go to project folder
vagrant up #Run virtual machine project
- Connect
vagrant ssh #connect to the ubuntu VM machine
exit #exit from VM machine
- Halt the vagrant machine now
vagrant halt #shutdown of VM machine