Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy and recreate vagrant/homestead machine?

I'm running Laravel on Vagrant Box (homestead)

When I'm doing vagrant up, I'm getting a message:

: A newer version of the box 'laravel/homestead' is available and already
: installed, but your Vagrant machine is running against
: version '6.3.0'. To update to version '7.1.0',
: destroy and recreate your machine.

What commands should I run and what are potential problems I should be prepared for?

like image 457
Yevgeniy Afanasyev Avatar asked Feb 24 '19 03:02

Yevgeniy Afanasyev


People also ask

How do I destroy vagrant machine?

Command: vagrant destroy [name|id] This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.

How do I delete a vagrant file?

You can remove the Vagrantfile by typing rm Vagrantfile at the command line, but it is not clear what you are trying to achieve. The vagrant init command will initialise a new virtual box by creating a default Vagrantfile. Since you already have one, it looks like you may already have run the vagrant init command.

Can I have more than one vagrant box?

You can definitely run multiple Vagrant boxes concurrently, as long as their configuration does not clash with one another in some breaking way, e.g. mapping the same network ports on the host, or using same box names/IDs inside the same provider.


1 Answers

You can create a second installation for Homestead before you destroy the working one.

1) follow official documentation on installing Installing The Homestead Vagrant Box, then, when Installing Homestead instead of this command

git clone https://github.com/laravel/homestead.git ~/Homestead

run this one

git clone https://github.com/laravel/homestead.git ~/MyHomestead

then you'll need to cd ~/MyHomestead and git checkout v8.4.0

now you need to go to ~\MyHomestead\scripts\homestead.rb file and replace homestead-7 to homestead-7-my it will give you a different name for virtual machine in your virtualbox.

Now you can follow the official documentation

1.1) and you can always destroy your old vagrant box from your vagrant folder usually ~/homestead by running

vagrant destroy 

2) create a new vagrant box by running

vagrant up --provision

3) get in to vagrant

vagrant ssh

4) go to your project (I assume you have a set of database migrations and seeders )

cd ~/code/myproject

4.1) you'll find redis and mysql is working there already.

5) create database

php artisan migrate

6) make SUPERVISOR works if you need it

7) make cron work if you need it

Done

like image 149
Yevgeniy Afanasyev Avatar answered Sep 30 '22 01:09

Yevgeniy Afanasyev