Jump Start PHP Environment, Ch. 4 - can't get Vagrant to start VirtualBox homestead.app

I’m sure I have Git, VirtualBox and Vagrant installed correctly. I’m following instructions to the letter from the book.

Not shown:

  • Edited my hosts file - 192.168.10.10 homestead.app
  • Ran bin/filefix.sh from Git-Bash

Here are the results when i entered the command “vagrant up” (I am wlbry and my computer is @Fogtown):

wlbry@Fogtown MINGW64 ~/homestead_improved-master
$ vagrant 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…
==> default: Setting the name of the VM: homestead_improved-master_default_1534687295558_23420
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports…
default: 80 (guest) => 8000 (host) (adapter 1)
default: 443 (guest) => 44300 (host) (adapter 1)
default: 3306 (guest) => 33060 (host) (adapter 1)
default: 5432 (guest) => 54320 (host) (adapter 1)
default: 8545 (guest) => 8545 (host) (adapter 1)
default: 30301 (guest) => 30301 (host) (adapter 1)
default: 30302 (guest) => 30302 (host) (adapter 1)
default: 30303 (guest) => 30303 (host) (adapter 1)
default: 30304 (guest) => 30304 (host) (adapter 1)
default: 30305 (guest) => 30305 (host) (adapter 1)
default: 30306 (guest) => 30306 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running ‘pre-boot’ VM customizations…
==> default: Booting VM…
==> default: Waiting for machine to boot. This may take a few minutes…
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured (“config.vm.boot_timeout” value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you’re using a custom box, make sure that networking is properly
working and you’re able to connect to the machine. It is a common
problem that networking isn’t setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout (“config.vm.boot_timeout”) value.

It says if I read that, I should be able to see the errors, but I’m brand new at this. I can’t see them.
If networking is not set up properly, I don’t know how to do that.

I also got the following error on VirtualBox:

VT-x/AMD-V hardware acceleration is not available on your system. Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.

All in all, my first attempt at virtualization appears to be a disaster. But I’m not giving up. Please assist!

That error you recieved is the issue.You will likely need to boot into your computer’s bios and enable VT-x (or AMD-V for AMD machines)

1 Like

OK, thanks, Tom. Here’s what I found about how to do that in Windows 10:

  1. Open settings and click /tap on the update and security icon.
  2. Click on recovery on the left side and click on restart now under advanced startup.
  3. After the PC restarts click on troubleshoot.
  4. Click on advanced options.
  5. Click on UEFI firmware settings.

Sound like a plan?

That looks about right, but it is different on every PC. Often you need to press a key (frequently F8 or F2) as the PC is starting up. You’ll need to consult the manual for your particular PC/motherboard.

TomB, thank you so very, very much. That worked like a charm. Nothing but success messages on Git-Bash, VirtualBox says it’s running, and I need to start studying some more to learn how to run this thing.

Thanks again, that was a HUGE help.

Bill Bryan

2 Likes

OK, next problem. I did edit my ‘hosts’ file - 192.168.10.10 homestead.app. The next thing the book says to do after getting the virtual machine running is to open a browser and go to homestead.app. But ALL my browsers are refusing to allow me to go there, because it has a self-signed certificate. I can copy the text of the certificate to the clipboard. It starts out like this:

https://homestead.app/

The certificate is not trusted because it is self-signed.

HTTP Strict Transport Security: true
HTTP Public Key Pinning: false

Certificate chain:

-----BEGIN CERTIFICATE----- (followed by the certificate, I won’t bother pasting that)
I can see that it’s using HSTS, and I learned a little about that, and followed the instructions I found here about chrome://net-internals/#hsts.

But when I enter http://homestead.app into the Query box, it isn’t found. And when I delete it using the Delete box, it has no effect. I just can’t look at that domain, even though it’s on my own computer. Very frustrating!

… and I’m used to adding exceptions, like when I work on my cPanel on my virtual server, but none of my browsers are allowing me to add an exception for this site.

Oh never mind, I figured it out.

Glad you got it sorted! It would be useful to post the solution for anyone who comes across the thread and has the same problem.

OK, actually I haven’t figured out how to open the homestead site in a browser. I had another issue, which was that if I clicked “Show” on VirtualBox, it gave me a black screen with “vagrant login”. And I couldn’t figure out what the login was, and it took a while before I realized I was looking at the wrong thing. Instead of trying to interact with the virtual machine on VirtualBox, what I needed to do was use Git-Bash and “vagrant ssh”. Then I can at least see the files in the virtual machine and use my (very) limited knowledge of Linux commands.

And I downloaded a box from Vagrant with Ubuntu 14.04, which I do have installed on an old laptop that doesn’t have enough RAM to run Win10 properly. So I’m familiar with the file structure and so forth.

But there’s no GUI. And I can’t reach any part of the VM with a browser. So I’m wondering if this VM idea is really for me. I’m not working with a team, I’m working in my home office. I’m trying to teach myself to be a WordPress developer, which means I have to learn PHP, MySQL, etc. and then be able to look at the changes I made in several browsers (and simulated mobile devices) to see how I’ve messed WordPress up (or not).

I’m actually having better luck watching video instruction from Lynda.com and using Dreamweaver and XAMPP to build/improve my sites. I know Dreamweaver had a reputation for creating bloated code, but that’s not true anymore, in fact it has a built-in feature that checks your code with W3C for standards compliance. It will open my files in all my various browsers, and is good with media queries. And when you’re just looking at the code, the interface isn’t that much different than Sublime Text or Notepad++ or any of the IDEs like Aptana or NetBeans.

I’m just trying to settle on one reliable environment where I can be comfortable and make sure I’m writing standards compliant code, and I stumbled on some books about virtualization that made it sound like a far superior solution than installing Apache, MySQL and PHP on my machine. But now that I’ve spent a couple days working on making it run and taken a look at it, I think I’m going to stick to XAMPP and Dreamweaver, with occasional resort to Sublime Text if there’s some need for it.

So … sorry to mislead anyone, but when I said “I figured it out” what I really sort of meant was “I figured out that virtualization using Git, VirtualBox and Vagrant are not my future.”

But I’m keeping an open mind. Talk me out of it, if I’m not thinking clearly here, por favor!

1 Like

There are benefits with using VMs besides “working with a team”. IMHO, you should give setting up VMs your best effort, but if you find it to be too much of a roadblock you should not let that stop you from getting started. There is much to learn and although being able to set up different environments quickly and easily is a plus it isn’t really a necessity until it is necessary. You will know when that time comes. You can always work in a less than ideal dev environment and revisit VMs later.

That’s correct. Since all you really need is the VM to run a web server and execute your code, you don’t need a GUI. You place your files in a directory that’s accessible on both your physical machine and the VM so you never really need to log in to it.

Generally it is, it’s closer to a real server so there’s less difference when you make your website live. It’s also easier. Unless you know what you’re doing setting up Apache (or preferably NGNIX), PHP and MySQL by yourself is not easy. XAMPP style packages also have their problems as you can only run one server at a time. With VMs you can have one PHP 5.6 vm, one PHP 7.2, etc and test your code on different PHP versions.

I’m not sure what your expectation is for a VM, but you’d still use the same editors whether you’re using a VM or running the server on your local machine.

I don’t know why you’re seeing the SSL error, last time I tried Homestead it just ran on http not https. However, [shameles plug]if you’re looking for a dead simple, zero config VM (which is also less than 100mb to download, homestead is 1.5gb!) check out my post here: https://r.je/vje-minimal-virtual-server.html [/shameless plug]

Well, thanks for the encouragement, guys. I’ll try a few more hours, see what I can do.

Here’s the thing – I AM typing: http://homestead.app with no https. My browsers WILL NOT allow me to view that site. If I can’t get past that somehow, I have no idea how I can use virtualization.

Here’s what I get from Chrome when I try to visit homestead.app:

Your connection is not private

Attackers might be trying to steal your information from homestead.app (for example, passwords, messages, or credit cards).

NET::ERR_CERT_AUTHORITY_INVALID
Subject: homestead.test

Issuer: homestead.test

Expires on: Aug 20, 2019

Current date: Aug 20, 2018

PEM encoded chain:
-----BEGIN CERTIFICATE-----
(skipping the code here)
-----END CERTIFICATE-----

homestead.app normally uses encryption to protect your information. When Google Chrome tried to connect to homestead.app this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be homestead.app, or a Wi-Fi sign-in screen has interrupted the connection. Your information is still secure because Google Chrome stopped the connection before any data was exchanged.

You cannot visit homestead.app right now because the website uses HSTS. Network errors and attacks are usually temporary, so this page will probably work later.

No, it’s probably not going to work later. I looked up HSTS and tried to fix that, as described above yesterday. So what do I do?

it looks like an issue with recent browsers, take a look at https://github.com/laravel/homestead/issues/755

Ah. And because of that problem, the book is maybe a little outdated. I opened my homestead.yaml file, and the mapping is:

- map: homestead.test
  to: /home/vagrant/Code/Project/public

So I shouldn’t be trying to reach homestead.app like it says in the book, I should be trying to reach homestead.test.

I am on my way out the door for some errands, will try it again with homestead.test and see what happens.

Thanks again, Tom.

OK, stuck around long enough to try it. I also had to edit my hosts file again:

192.168.10.10 homestead.test

So that I didn’t get a DNS error message.

When I did those two things, I got the success message it says I should get in the book – no input file specified. Next I’m supposed to create an index.php and try again. I will do that later today.

… and I’m going to try your Shameless Plug file later, too. That looks interesting!

I was so thrilled to reach homestead.test, I gave Vagrant an ‘omg’. :sunglasses:

vagrant@homestead:/$ omg

Command ‘omg’ not found, did you mean:

command ‘mog’ from deb mazeofgalious
command ‘zomg’ from deb zomg
command ‘om’ from deb omhacks
command ‘omp’ from deb openvas-cli
command ‘vmg’ from deb vmg
command ‘mg’ from deb mg

Try: sudo apt install ‘deb name’

OK, I installed the Shameless Plug box, :rofl: I’ll try some work on that later. For now I’m going to follow along with the book, which means using the Homestead site. I’ll just call that (homestead) in parentheses because the real name is much longer.

I created folders, /(homestead)/Project and /(homestead)/Project/public, and created an index.php file in the /public folder, and when I visited on Chrome, it was there. That’s huge progress for me, after wallowing in the mire for three days. So now I think I have some slight grasp on a workflow:

  1. I start a VM with Vagrant. Somehow that VM is running Ubuntu, Apache (or maybe Nginx), and MySQL (or maybe MariaDB), and is ready to act like a web server immediately. I just have to find the shared folders and put my files in there, and when I want to look at the results, use the browser. I can create entire projects in the shared folders. In fact, I copied a project I’m working on into the /(homestead)/Project/public/ folder, and it’s working. It’s even finding and applying the stylesheets.

  2. If I suspend, halt, or destroy the VM, the shared folders and files will still be there the next time I vagrant up.

  3. If I can get Dreamweaver to see the project as a local server using the ‘Sites’ function of DW, then I can work on the files using DW. This is the part I haven’t quite gotten to yet. Sublime Text is easier, I just open files in the shared folders.

  4. And then later I should find out what environment my hosting company is using on my virtual private server, and find a virtualbox that reproduces that. That way, I’m using the same environment as will be used to host my projects when they go into production.

Is that all correct? Is that where I’m supposed to be headed? How do I find what the shared files should be on different virtualboxes? Like on the Shameless Plug box, what folders do I use as shared folders?

Again, thanks for the words of encouragement last night, I was pretty frustrated after running into too many problems trying to get this set up. I don’t mind admitting, when I moved my current project into the VM without Apache or MySQL running on my computer and the site worked perfectly, I finally realized the value of this virtualization stuff. Sometimes you have to go through a nightmare to come out on the other side.

Bill

OMG, I got Dreamweaver working. It’s finding the site, and correctly interpreting the PHP and CSS files. It looks GREAT.

I think I passed Virtualization 101. Now I just need to figure out how to get a box that matches my VPS.
For many of my low-traffic sites, I’m using BlueHost. They give the following server information:

Apache Version 2.4.34
PHP Version 7.0.31
MySQL Version 5.6.39-83.1
Architecture x86_64
Operating System linux

So next I need to find a virtual box with that environment, and find what to use as shared folders, and I’m set, isn’t that right?

Never mind, I am changing hosting. I was going cheap, shared hosting at BlueHost. I decided to get a VPS account at InMotion.com. It’s going to take a couple days to switch everything over.

Regardless of which hosting environment you are using, if you want parity between your host and you development environment I suggest PuPHPet: https://puphpet.com/ it requires configuration but you can choose all the specific software versions.