Installing Homestead in Mac OS X

Homestead is the simple way that YOU, code artisan want to build your project in your local computer and you want have setting of your local computer same as your production server. Here is Homestead come to you.

Homestead is a vagrant box that laravel special build for simplify developer work.

First of all you need to download and install Virtualbox and Vagrant before installing Homestead in your local computer.

Step 1 Installing composer

~> curl -sS https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /Users/you/composer.phar
Use it: php composer.phar

once you have composer.phar downloaded, make it globally

~> sudo mv composer.phar /usr/local/bin/composer

add alias for composer in ~/.bash_profile

alias composer="php /usr/local/bin/composer.phar"

checking composer version

~> composer --version
Composer version 1.0-dev (b23a3cd36870ff0eefc161a4638d9fcf49d998ba)\
2014-11-21 17:59:11

Step 2 Adding ssh keys

check in your local computer if there is already ssh keys usually in ~/.ssh directory. If there is 2 files id_rsa and id_rsa.pub you don’t need to generate ssh keys again.

If you don’t see both files, you can generate it.

~> ssh-keygen -t rsa -C "your@email.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa):
Created directory '/Users/you/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Step 3 Adding Homestead box

~> vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
    box: URL: https://vagrantcloud.com/laravel/homstead

it take a little while for download the box. If you already download, you can adding this box manually ( i assume that homestead.box file placed in your Download directory)

~> vagrant box add laravel/homestead ~/Download/homestead.box
==> box: Loading metadata for box 'laravel/homestead'
    box: URL: https://vagrantcloud.com/laravel/homstead

Step 4 Installing Homestead

~> composer global require "laravel/homestead=~2.0"
Changed current directory to /home/you/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing symfony/process (v2.5.7)
    Loading from cache

  - Installing symfony/console (v2.5.7)
    Loading from cache

  - Installing laravel/homestead (v2.0.7)
    Loading from cache

Writing lock file
Generating autoload files
  • updating you PATH in ~/.bash_profile
    export PATH="~/.composer/vendor/bin:vendor/bin:$PATH"

save and then reload using:

    ~> source ~/.bash_profile
  • Initializing Homestead
    ~> homestead init
    Creating Homestead.yaml file...
    Homestead.yaml file created at: /home/you/.homestead/Homestead.yaml

there is generate 3 files in ~/.homestead/ directory in your local computer. Go to ~/.homestead            directory and edit Homestead.yaml

---
ip:"192.168.10.10"
memory: 2048
cpus:1
authorize: ~/.ssh/id_rsa.pub
keys: - ~/.ssh/id_rsa
folders: - map: ~/Code
           to: /home/vagrant/Code
sites: - map: homestead.app
         to: /home/vagrant/Code/Laravel/public
databases: - homestead
variables: - key: APP_ENV
value: local

note:

  • folders : map-> here is your local directory that you want to share with VM ( usually it as /public_html directory). to -> here is in vm directory that linking your /public_html directory
  •  sites : map -> local domain to point your project. to-> project directory in vm that consist file of your project

in this example i use /Code directory as my public_html directory, you can create ~/Code directory before (do in your local computer) .

Step 5 Adding Local Domain

edit your /etc/hosts file to point your local domain and homestead IP

192.168.10.10 homestead.app

Step 6 Bringing Up Homestead

~>homestead up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default Checking if box 'laravel/homestead' is up to date...

you can log on to homestead using

~>homestead ssh
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-11-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Step 7 Installing Laravel

go to your public_html ( /Code ) directory in your local computer and then type:

~> composer global require "laravel/installer=~1.1"
Changed current directory to /Users/you/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing guzzlehttp/streams (2.1.0)
    Downloading: 100%

  - Installing guzzlehttp/guzzle (4.2.3)
    Downloading: 100%

  - Installing laravel/installer (v1.1.3)
    Downloading: 100%

Writing lock file
Generating autoload files

Step 8 Checking in Browser

go to your favorite browser and type your local domain  homestead.app for checking if Laravel success installed in our homestead box .

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s