Coding with Laravel: Installing Homestead on a Mac

If you instead want to install Laravel on an online server, here my new article on how to install on a Digital Ocean:

I have only been learning Laravel for a year, but below is the Homestead install process which has worked best for me. Homestead is Laravel’s own development environment, powered by Vagrant. (Replace all references to “ProjectName” with a short name for your own project.)

  1. Install XCode from the App Store. Open it, and accept the user agreement.
  2. Install VirtualBox:
  3. Install Vagrant:
  4. To the command line (Mac OS Terminal, or iTerm)! Create local ssh key, if you haven’t on this computer before:
    $ ssh-keygen -t rsa -C ""
  5. Install Composer, Homestead, and initialize:
    $ curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer  
    $ mkdir ~/web
    $ mkdir ~/web/sites
    $ mkdir ~/web/sites/ProjectName
    $ cd ~/web
    $ git clone Homestead
    $ cd Homestead
    $ bash
  6. Edit paths in Homestead.yaml:
    $ nano ~/.homestead/Homestead.yaml

    Change this chunk of code:

    	- map: ~/Code
    	  to: /home/vagrant/Code
        - map:
          to: /home/vagrant/Code/Laravel/public

    To this chunk of code:

    	- map: ~/web/sites/ProjectName
    	  to: /home/vagrant/Code
        - map:
          to: /home/vagrant/Code/ProjectName/public
  7. Edit the hosts file:
    $ sudo nano /etc/hosts

    Add one line to the bottom:
  8. Launch your local server (“vagrant up”), log into it, and install Laravel!…
    $ cd ~/web/Homestead
    $ vagrant up
    $ vagrant ssh
    $ cd /home/vagrant/Code
    $ composer global require "laravel/installer"
    $ composer create-project laravel/laravel ProjectName "5.3.*"

Now you should be able to confirm your successful installation by pulling up in your browser!

  • If you like, you can now connect to your server’s database with something like Sequel Pro, and the following default login info…. Host: , Username: homestead , Password: secret , Port: 33060 , Database: homestead .

And you’re ready to start installing more Laravel packages and building your own world. Here, inside your virtual vagrant server via SSH, you can enter your new project’s main composer directory (/home/vagrant/Code/ProjectName), which displays in your actual machine’s file system in ~/web/sites/ProjectName/ProjectName (that’s within your main user account folder alongside Documents, Pictures, etc).

$ cd ProjectName

You could do things like install Laravel’s out-of-the-box user authentication tools:

$ php artisan make:auth

Or install the SurvLoop software I’ve started:
Or anything else you can imagine: