9

I'm running into an issue getting vagrant share to work in conjunction with the laravel homestead vagrant box. My homestead.yaml file looks like:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: /Users/me/.ssh/id_rsa.pub

keys:
    - /Users/me/.ssh/id_rsa

folders:
    - map: /Users/me/Projects/laravel
      to: /home/vagrant/laravel

sites:
    - map: laravel.app
      to: /home/vagrant/laravel/public

variables:
    - key: APP_ENV
      value: local

When I hit http://laravel.app:8000 - everything works fine. When I start up vagrant share the URL that's generated returns the error No input file specified.

I'm stumped. Searching Google for hours hasn't resulted in a solution. I'm sure it's just some basic configuration thing and I'm not connecting the dots. Any pointers would be appreciated. Thanks!

rfoote
  • 121
  • 2
  • 4

4 Answers4

9

There's a solution without having to do anything on your homestead VM.

You can install a program called ngrok which does a similar thing to vagrant share but works better with the multiple sites that Homestead uses. You will need to sign up for an account but basic usage is free.

Run: ngrok http -host-header=rewrite your-local-site.app:80

(Where your-local-site.app is what's used for the map directive in your Homestead.yaml file)

Then your site will be available globally on the url that ngrok gives you.

Richard
  • 39,052
  • 6
  • 25
  • 29
7

@sanaco's answer missed some steps for me. This is full command to create the share (after logging in)

vagrant share --http 80 --name silly-sausage

On completion the command will out put the share URL which should look like this

http://silly-sausage.vagrantshare.com

Once the share is up you need to ssh into the vagrant box with

 vagrant ssh

And run

serve silly-sausage.vagrantshare.com ~/Code/project/path/public 

Without the http flag vagrant assigns 443 to http which makes nginx complain about HTTPS port being used for HTTP connection.

By specifying the name you only need to do the serve command first time.

Mike Miller
  • 3,071
  • 3
  • 25
  • 32
  • Mike could you take a look at my question in this thread: https://stackoverflow.com/questions/55108320/vagrant-share-and-laravel-homestead – padawanTony Mar 11 '19 at 18:40
  • 1
    @padawanTony use Ngrok with the `--host-header` set to the name of your laravel app eg `myproject.dev`. its easier to setup and keep working – Mike Miller Mar 12 '19 at 21:13
  • Thanks for the answer Mike. Can you post a complete answer (step-by-step) to my thread? I have never used ngrok before. Thanks. – padawanTony Mar 13 '19 at 22:06
3

The first step is to create an account for Vagrant Cloud, if you haven't already.

Once you've done that, in your terminal (not logged into the Homestead machine) run vagrant login and login with your details.

Then run vagrant global-status to find the ID of the vagrant machine Homestead is running on.

Run vagrant share 123a4 (where 123a4 is the machine ID) and your machine will be shared!

Note that you might have to set up your Nginx configuration to listen for the URL that has been generated for you so it points to the correct site on the machine.

Sacha
  • 559
  • 7
  • 23
  • 1
    Wow. Thank you. I've been trying to figure this out for the longest time. – yan Jun 05 '15 at 17:25
  • Can you explain the last paragraph? How do you "listen to the URL"? – Robo Robok Nov 17 '15 at 23:29
  • You need to map the URL to the directory on your vagrant machine. So, using Homestead, you can run `serve url-to-vagrant-cloud.com ~/path/to/your/code/public` which will do that for you. – Sacha Nov 18 '15 at 09:38
  • @Sacha could you take a look at my question in this thread: https://stackoverflow.com/questions/55108320/vagrant-share-laravel-homestead-ubuntu – padawanTony Mar 12 '19 at 10:04
0

Try this command in your homestead directory: vagrant provision

To get share URL use this command: vagrant share

Sometimes it doesn't worke on windows. Use vagrant share --http 8000

8000 is port as homestead uses port forwarding 8000 -> 80

Note: To use vagrant share you must have ngrok installed.

PHP Worm...
  • 4,109
  • 1
  • 25
  • 48