Vagrant Full Intro

Some of the main parts

vagrant -v

Must have a Vagrantfile – the core file . Written in ruby

it has 5 main parts:
– config.vm.box – OS ( ubuntu16.04 say )
– config.vm.provider – virtualbox ( could be hyperv , etc… )
– config.vm.network – how the host sees the box ( IP , PORTS , etc … )
– config.vm.synced_folder – Ho to access the files from the host ( your computer , shared_folder )
– config.vm.provision – Describe the setup ( lamp, mean or nodejs , etc.. )

Basic setupVagrant.configure("2") do |config|
config.vm.box = "ubuntu/trustee64"
# Provide Settings
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpu = 4
end
# Network Settings
config.vm.network "private_network", ip: "192.168.33.10"
# Folder setting ( local / vmbox location / permissions) nfs only works (mac/linux)
config.vm.synced_folder ".", "/var/www/html", :nfs => { :mount options => ["dmode=777", "fmode=666"] }
# Provision settings
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y apache2
SHELL
end

Adding a hostname
Add a line to your local machine ( not the guest VM ):

192.168.33.10.  testdemo.local www.testdemo.local

Doing changes

vagrant reload | vagrant halt && vagrant up

NOTE

By creating a new box, do updates for the sources
Later continue with the installations -y

For ease of use of installing a Stack…

Remove Provision settings from the confuguration

Instead of INLINE , we want PATH

config.vm.provision "SHELL", path: "bootstrap.sh" // could also be - install.sh

update, ugrade, git, apache2, a2enmode rewrite, ( Onrej PPA repo ) , PHP, libapache2-mod-php, service apache2 restart, php mods, SET MYSQL PASS, mysql-server, php-mysql, sudo serrvice apache2 restrart
# Set MySql Pass
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'

 

Get in the box

vagrant ssh
mysql -uroot -proot

Was this article helpful?

Related Articles

Leave A Comment?