Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jrath5's avatar

Installing Laravel/Homestead

I'm brand new to coding. I am working on a project with a developer, and he says he will be "running Vagrant via Homestead." I've tried to follow a couple installation guides online. I wonder if I have switched between too many sites and now I've got everything messed up within my terminal.

I am using a Mac and running Sierra. Here's what I've done so far (The instructions I was following originally can be found here: https://laravel.com/docs/4.2/homestead ):

  1. I downloaded VirtualBox 5.1.10 platform package for Mac.

  2. I downloaded the VirtualBox 5.1.10 SDK

  3. I downloaded Vagrant for Mac OS X from https://www.vagrantup.com/downloads.html

  4. Then I ran the following code in my terminal:

    vagrant box add laravel/homestead

When I ran this code, I got the following error:

Josephs-MBP:~ Joey$ vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://atlas.hashicorp.com/laravel/homestead
==> box: Adding box 'laravel/homestead' (v0.6.1) for provider: vmware_desktop
The box you're attempting to add already exists. Remove it before
adding it again or add it with the `--force` flag.

Name: laravel/homestead
Provider: vmware_desktop
Version: 0.6.1

I'm not sure how to remove before adding again. This is my first roadblock.

  1. Next, I went to getcomposer.org and followed these instructions to install: https://www.youtube.com/watch?v=BnIZVHmROkk This worked well. When I had finished, I was able to type 'composer' into my Terminal and it would run.

  2. The next step in the instructions totally threw me for a loop. Maybe it didn't work because of the issue I had in #4 above? Here's what the directions say:

Installing Homestead

With Composer + PHP Tool

Once the box has been added to your Vagrant installation, you are ready to install the Homestead CLI tool using the Composer global command:

composer global require "laravel/homestead=~2.0" Make sure to place the ~/.composer/vendor/bin directory in your PATH so the homestead executable is found when you run the homestead command in your terminal.

Once you have installed the Homestead CLI tool, run the init command to create the Homestead.yaml configuration file:

homestead init

The Homestead.yaml file will be placed in the ~/.homestead directory. If you're using a Mac or Linux system, you may edit Homestead.yaml file by running the homestead edit command in your terminal:

homestead edit

When this turned into a dead end, I tried following these instructions: http://petericebear.github.io/installing-laravel-homestead-osx-20160514/

I ran the following line of code as directed:

sudo -s 'echo "~/.composer/vendor/bin" > /etc/paths.d/40-composer'

and I received the following error:

Josephs-MBP:~ Joey$ sudo -s 'echo "~/.composer/vendor/bin" > /etc/paths.d/40-composer'

Password: /bin/bash: echo "~/.composer/vendor/bin" > /etc/paths.d/40-composer: No such file or directory Josephs-MBP:~ Joey$

This is likely a poorly written question, but maybe someone can help me get this all straightened out. Hoping I won't end up done trying to learn PHP/Laravel before I even get started.

Thanks!

0 likes
13 replies
ejdelmonico's avatar

You should look at the install process for Laravel 5.3 and then in Homestead section for the latest process.

cd ~

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

It will install homestead in you Home directory with the driectory name of Homestead.

Make sure you can bring up the virtualbox GUI to check the install. Next, which vagrant to see if vagrant installed properly. Next,

cd Homestead
bash init.sh
1 like
jrath5's avatar

Maybe this isn't the place for me to be starting. I appreciate your feedback, but I can't quite interpret what you're telling me.

When I ran:

cd ~

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

my Terminal said:

Josephs-MBP:~ Joey$ git clone
https://github.com/laravel/homestead.git Homestead fatal:     destination path 'Homestead' already exists and is not an empty         directory.

Then I ran:

cd Homestead
bash init.sh

and my Terminal said:

Josephs-MBP:Homestead Joey$ bash init.sh
Homestead initialized!

It feels like progress, but I'm still not sure if I'm able to get things up and running.

ejdelmonico's avatar

You got that message because you already have a Homestead directory. Just rename that one Homestead-old and Go through the process again. Obviously you initialized homestead so you can skip that. If you have to edit it again, it is located at ~/.homestead directory.

Ok, let's start over. You have a MBpro with Sierra. From what I gather you installed VirtualBox 5.1 and Vagrant 64-bit for Mac. To check if they are installed properly, open the VirtualBox app from your applications directory to see if the GUI (graphical user interface) opens properly. If it does, then it is probably a good install.

Then, open your Terminal app...and type which vagrant and you should see a valid path to the vagrant executable...the install worked. So, you can now assume both installs are good. Still in Terminal, type cd ~ to make sure you are in your Home directory and type vagrant box add laravel/homestead Then, install Homestead by this command git clone https://github.com/laravel/homestead.git Homestead. Once that finishes, type bash init.sh and fill in the values for your homestead.yaml file per the docs or videos on this site.

Did you watch the numerous videos around the web showing the process?

1 like
jrath5's avatar

Thanks for working with me on this. I really appreciate it.

You said in your first paragraph "Just rename that one Homestead-old and go through the process again." I'm not sure how to do that... :-\

I opened VirtualBox and the GUI displayed. I had made the mistake of only downloading the program without running the installation file. Now it's all set.

Regarding the last paragraph you sent, this is how far I got before receiving an error:

Josephs-MBP:Homestead Joey$ which vagrant
/usr/local/bin/vagrant
Josephs-MBP:Homestead Joey$ cd ~
Josephs-MBP:~ Joey$ vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://atlas.hashicorp.com/laravel/homestead
==> box: Adding box 'laravel/homestead' (v0.6.1) for provider: vmware_desktop
The box you're attempting to add already exists. Remove it before
adding it again or add it with the `--force` flag.

Name: laravel/homestead
Provider: vmware_desktop
Version: 0.6.1

I see it wants me to remove it and add it again, but I don't know how to do that.

Thanks again for your help!

ejdelmonico's avatar

On the Mac, open Finder and click on your Home directory (called Joey or whatever you named it) and look for the Homestead directory. Just highlight it and tap on keyboard. That open the renaming function. The, just hit the right arrow to go to the end of the file name and type "-old" and click away from it. The file should now be renamed.

It looks like you already have the Vagrant box added so you can skip that step. That is what the error message is telling you. If you suspect the Vagrant box did not download properly, then type vagrant box remove laravel/homestead to delete the box and add the box again. In fact, that is just how Vagrant works so you can do that with any box.

It seems like you are using vmware which I never used. So, you can remove virtualbox software if necessary and disreguard that step. Additonally, there are special requirements for that if you look at the Laravel docs here https://laravel.com/docs/5.3/homestead#installation-and-setup

1 like
ejdelmonico's avatar

I would recommend starting out with either Atom or Sublime Text 3. Most folks use Sublime Text 3 but I don't know if you want to buy a license after the trial is up (it doesn't stop working at the end of trial). I use Sublime Text3 and PhpStorm for large projects because of its features. Jeffrey has an entire course on setting up Sublime Text 3.

1 like
jrath5's avatar

Thanks! I've got Atom downloaded.

Two issues:

ONE

I'm at the 7:33 mark of the above referenced Youtube video. He talks about bringing over his web directory to the text editor. I didn't have a www or web directory on my computer. Can I just create it? Users/myname/web? And if I do, do I need to have anything inside of that folder in order to accomplish what the video's author is explaining? In the video, it appears the Homestead file is inside the Users/myname/web file. For that reason, I went into my Finder and grabbed the Homestead folder and dragged it into my newly created myname/web folder. Have I done this correctly?

TWO

To open Homestead.yaml in Atom, I went to my Finder and found it here:

Users/myname/web/Homestead/src/stubs/Homestead.yaml.

I "Opened with" Atom, and I found the same code on the screen as in the video. However, in the video, I noticed his path in the left margin of the text editor was:

.homestead/Homestead.yaml

The following files were listed along with Homestead.yaml:

after.sh; and alliases

My screen was the same with a couple exceptions:

a. My path in the left margin of the text editor was:

stubs/Homestead.yaml

b. The following files were listed along with Homestead.yaml:

after.sh; alliases; and LocalizedVagrantfile

Are either of these differences between my screen and the video author's screen cause for concern?

Thanks in advance!

ejdelmonico's avatar

You do not need to move the Homestead folder. But, you can house Homestead wherever you prefer. Most of us have it in our Home directory. Homestead.yaml needs to point to you project working directory. Everything you do like creating a new project, etc will occur in the project directory. The way most of work with a text editor is to just open the project directory with the editor. Nothing special is required.

I haven't watched the videos other that what is on this site. And, I do not use Atom. I use Sublime Text 3 and PhpStorm as most do.

1 like
jrath5's avatar

You mentioned buying Sublime Text 3. Why would I buy a license if it continues working after the trial ends?

ejdelmonico's avatar

Why? Because it's the right thing to do. You should understand how much work goes in to something like that. It was developed for developers and that's why they do not restrict you when the trial expires. Atom is still pretty young and is lacking in many areas.

Also, you have a .homestead file in your home directory that houses your Homestead.yaml. You must edit that file as well as /etc/hosts as instructed in the docs.

1 like
jrath5's avatar

Thanks for your reply. If I can get over this initial hump and make it past the trial period, I will purchase a license. By the way, when I downloaded Sublime Text 3 I got this message:

Sublime Text Build 3126.dmg https://download.sublimetext.com/Sublime%20Text%20Build%203126.dmg This type of file can harm your computer. Do you want to keep Sublime Text Build 3126.dmg anyway?

I had trouble with the video I watched here at Laracasts regarding installation of all the software needed in order to use Laravel/Homestead. Once I can get it installed, I'd like to continue watching videos here. Until then, it looks like I'll have to use the video I mentioned. At this point I just used the vagrant up command. I did edit the folder and sites paths within the homestead.yaml file. However, I haven't run into anything yet about /etc/hosts. When you say "in the docs," I'm not sure what you mean. Again, I'm brand new to this and it's entirely possible that I haven't started in the appropriate place.

Oh well. Doing my best.

Please or to participate in this conversation.