Reputation: 822
I'm trying to run vagrant homestead laravel virtual machine, but can't. I follow official instructions.
My steps:
vagrant box add laravel/homestead
downloaded.git clone https://github.com/laravel/homestead.git Homestead
. I can't see any *.yaml
file in root directory as I see in this video.Git bash
and go to Homestead
folder, than type sh init.sh
. Output:
$sh init.sh
cp: overwrite `/z/.homestead/Homestead.yaml'?`
cp: overwrite `/z/.homestead/after.sh'?`
cp: overwrite `/z/.homestead/aliases.sh'?`
Homestead initialized!
But I can't see Homestead.yaml
file. Also my C:\Users\user\
folder not contains any .homestead
folder.
vagrant up
Output:
c:/projects/Homestead/scripts/homestead.rb:91:in `read': No such file or directory - Z:/.ssh/id_rsa.pub (Errno::ENOENT)
from c:/projects/Homestead/scripts/homestead.rb:91:in `block in configure'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/kernel_v2/config/vm_provisioner.rb:72:in `call'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/kernel_v2/config/vm_provisioner.rb:72:in `add_config'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/kernel_v2/config/vm.rb:317:in `provision'
from c:/projects/Homestead/scripts/homestead.rb:89:in `configure'
from c:/projects/Homestead/Vagrantfile:20:in `block in <top (required)>'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/v2/loader.rb:37:in `call'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/v2/loader.rb:37:in `load'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/loader.rb:103:in `block (2 levels) in load'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/loader.rb:97:in `each'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/loader.rb:97:in `block in load'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/loader.rb:94:in `each'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/config/loader.rb:94:in `load'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/vagrantfile.rb:28:in `initialize'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:689:in `new'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:689:in `vagrantfile'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:441:in `host'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:207:in `block in action_runner'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:33:in `call'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:33:in `run'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:428:in `hook'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:671:in `unload'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:177:in `ensure in <main>'
from C:/Vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:177:in `<main>'
What did I miss in my installation?
UPDATE:
I found these files in an already mounted disk Z:\ . Why bash creates files on Z:\
when I start init.sh
from C:\
?
Cygwin creates files in user profile folder (.homestead
directory), but it also not making vagrant up
to work.
UPDATE 2:
Now both vagrant up
and homestead up
commands give this output:
c:\projects\laravel5>homestead up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* A box must be specified.
Upvotes: 0
Views: 2156
Reputation: 141
I've followed the instructions on Solg's answer and they work well. Thank you very much! I didn't found this answer anywhere else.
There are some reservations, though. I've found out that if you sudo su
before installing laravel with composer global require "laravel/installer=~1.1"
it will install laravel for the root user, and that is not what we should want, as it saves laravel on /root/.composer
folder and it's only accessible by the root user.
A better aproach would be running sudo composer global require "laravel/installer=~1.1"
without sudo su
, so laravel gets fully installed with it's requirements, but in the vagrant user directory instead.
Actually, i've come up with an even better option (in my opinion) that is to put some code on the after.sh
, located in .homestead
folder, to be automatically executed when the VM goes up (by running vagrant up
):
if [ ! -d $HOME/.composer/vendor/bin ]; then
echo "Installing Laravel Installer!!!"
sudo composer global require "laravel/installer=~1.1"
echo "\nPATH=$HOME/.composer/vendor/bin:$PATH" >>$HOME/.profile
fi
This way, even if you destroy your VM, when you vagrant up
it again, laravel will be installed and laravel
command added to bash.
Hope it can help you.
Upvotes: 1
Reputation: 822
Did it on Windows 7 and Windows 8 machines.
Steps:
Git for Windows
.cd ~
in Git Bash than you must move to your profile folder. Also Git Bash starts with the same folder.Vagrant
and VirtualBox
.vagrant box add laravel/homestead
.git clone https://github.com/laravel/homestead.git Homestead
.cd ~/.ssh
and type ssh-keygen -t rsa -C "yourmail@you" -f homestead
.~/Homestead
and type sh init.sh
. It creates 3 files in ~/.homestead
folder.Edit your Homestead.yaml
file. My config (#
for comment line):
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
#Paths to your generated SHH keys
authorize: ~/.ssh/homestead.pub
keys:
- ~/.ssh/homestead
#Folder sharing
folders:
- map: C:\projects\Laravels <----your Windows mapped folder!
to: /home/vagrant/Code <--- VM mapped folder. Do not change it.
#Add your sites here
sites:
- map: test.lar
to: /home/vagrant/Code/test.lar/public
- map: test2.lar
to: /home/vagrant/Code/test2.lar/public
#I commented it because do not want to re-create DB on each VM run
#databases:
# - homestead
variables:
- key: APP_ENV
value: local
Edit hosts
file on \Windows\System32\drivers\etc
folder and add 2 lines to the end:
192.168.10.10 test.lar
192.168.10.10 test2.lar
Now move to ~/Homestead
and start your machine with vagrant up
. In most situations you need to run Git Bash as administrator. After this command you can see in VirtualBox running machine with name Homestead.
No input file specified.
All is OK.vagrant ssh
and become root user with sudo su
.laravel
command, type this: composer global require "laravel/installer=~1.1"
export PATH="$PATH:~/.composer/vendor/bin"
and source ~/.bashrc
. More info.cd /home/laravel/Code
and create your first project with laravel new test.lar
.Laravel 5
on the center of the screen. It works! Files in your mapped folder are automatically synchronized.That's all. Mostly i used this tutorial and official in parts.
Upvotes: 3