Laravel 5.1 Homestead Install Issues and Fixes

While installing Laravel 5.1, following along via their directions, I ran into some area’s that for me required clarification, and some things that didn’t work directly out of the box at all (at least in my case).  In case others have such issues, I’m making this post.

I installed Homestead via the vagrant route.  After

vagrant box add laravel/homestead

was finished, there was no baseline project (which I perhaps improperly expected). So next I cloned the Homestead repository into my ~ directory:

git clone Homestead

And subsequently cd’d into ~/Homestead, and ran the bash script:


Ok, now we’re starting to make some progress. It did it’s thing, and created a ~/.homestead directory. In this directory can be found the homestead.yaml file.

Something that wasn’t clear to me until after mucking around a bit was the necessity of creating a ~/Code directory. I elected to create it within ~/Homestead (i.e. ~/Homestead/Code), but their docs show ~/Code. Whatever works for you.

Now, of course, we’ve mapped some directories. But, there’s no Laravel Project to be found. We have to create that ( yes, I know about what happens when I ‘ASSume‘. But the assumption I had made was that since Homestead was designed to be an out of the box way for one to reach Laravel Nirvana, a basic Laravel framework would already be set up. And the saying was true on my end at least… ). So, cd into where ever you decided to put your /Code directory. Again, for me it’s at ~/Homestead/Code. I have composer already installed on my system, and in my path. If you don’t, you’ll have to first take care of installing composer, etc.  [You don’t need to be in /Code for this next command, but you will need to be in it for the following one]

composer global require "laravel/installer=~1.1"

After this, and in retrospect, an easier way to create the Code directory might have been to simply:

laravel new Code

from within whatever directory you want /Code placed. In my case, ~/Homestead/Code. I did this without the benefit of hindsight, so I did the ‘laravel new foo‘, and then copied everything from foo directly into /Code, throwing away the foo folder. Either way, what we want is all of Laravel’s code setting directly in our /Code directory.

Oh, capital! Now things should work just fine…
From (in my case) ~/Homestead/Code:

vagrant up

After it’s booted up and stabilized (and having followed the directions on their site about making an addition to your hosts file, you should be able to navigate to: in your browser, and… and… ‘no input blah blah‘.

So, you’ll notice that in the yaml file (as per their website), you’ll find this:

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

But what WE have after installing Laravel via composer is all it’s working’s in our /Code directory… So, /public is NOT /Code/Laravel/Public, it’s /Code/Public/  Here’s now it needs to read based on this article:

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

If you’re sensing I’m starting to get a bit miffed, you’re right.  BUT, in fairness, I’ve had too much coffee, and had a long day.  Maybe their directions are completely clear… and it’s just me.  I’m willing to own that.

Fine.  So, ( from terminal, where we executed ‘vagrant up‘ ):

vagrant ssh
cd /etc/nginx/sites-enabled
sudo nano

As of this writing, note the 5th line down:  root “/home/vagrant/Code/Laravel/Public“;

This needs to be changed to:

root "/home/vagrant/Code/Public";

Save it:

C-o, [return/enter], C-x

Then, restart nginx to read it in:

service restart nginx

And, just for sanity’s sake, in your /Code directory, open Laravel’s /config/app.php. The first directive to set application debug mode– it comes set to false. Make it true:

'debug' => env('APP_DEBUG',true);

Now, surely we’re ready to experience some of that Developer Pleasure… navigate or reload the page: and… DOH!!  A bunch of debug stuff regarding encryption faults!  WTF?  OK, can we fix it? Yes we can:  with terminal cd’d into the /Code folder:

php artisan key:generate

It will return ‘Application key [ x ] set successfully’, where x is an encryption string ( not the literal letter x ). Now, maybe it did set it successfully somewhere, but I didn’t see it happen in my file, so here’s what to do next:
Round about line 81-ish in ( Laravel’s directory structure in your /Code folder) /config/app.php: see the commentary above for ‘Encryption Key’? You’ll see the key with a text string in it, I don’t remember what it was, but it’s bogus. It is here you want to cut and paste the ‘Application key [ x ] above. So, ( remembering that the ‘x’ is meant to be an encryption string within the braces [ x ] ), copy ONLY the string, NOT the braces, and paste it thus:

'key' => env('APP_KEY', 'x'),

NOW, finally, we can experience the pleasure we were promised.

I don’t mean to rag things, my tone is meant to be good natured. I actually like Laravel– honest. But, there is some room for if not improvement, at least more clarity in the instructions. That’s my two cents.


Leave a Reply

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

You are commenting using your 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