简体   繁体   English

流浪者与laravel宅基地分享

[英]vagrant share with laravel homestead

I'm running into an issue getting vagrant share to work in conjunction with the laravel homestead vagrant box. 我正在遇到一个问题,让流浪者分享与laravel宅基流浪盒一起工作。 My homestead.yaml file looks like: 我的homestead.yaml文件看起来像:

---
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. 当我点击http://laravel.app:8000时 - 一切正常。 When I start up vagrant share the URL that's generated returns the error No input file specified. 当我启动vagrant share ,生成的URL返回错误No input file specified.

I'm stumped. 我很难过。 Searching Google for hours hasn't resulted in a solution. 在Google上搜索几个小时并没有找到解决方案。 I'm sure it's just some basic configuration thing and I'm not connecting the dots. 我确定这只是一些基本配置的东西而且我没有连接点。 Any pointers would be appreciated. 任何指针将不胜感激。 Thanks! 谢谢!

@sanaco's answer missed some steps for me. @ sanaco的回答错过了我的一些步骤。 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 完成后,该命令将输出应该如下所示的共享URL

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. 没有http标志,vagrant将443分配给http,这使得nginx抱怨用于HTTP连接的HTTPS端口。

By specifying the name you only need to do the serve command first time. 通过指定名称,您只需要第一次执行serve命令。

There's a solution without having to do anything on your homestead VM. 有一个解决方案,无需在家园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. 你可以安装一个名为ngrok的程序, 它对 vagrant share做类似的事情,但对于Homestead使用的多个站点更好。 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 运行: 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) (其中your-local-site.app是您在Homestead.yaml文件中用于map指令的内容)

Then your site will be available globally on the url that ngrok gives you. 然后,您的网站将在全球范围内通过ngrok为您提供的网址提供。

The first step is to create an account for Vagrant Cloud , if you haven't already. 第一步是为Vagrant Cloud创建一个帐户(如果您还没有)。

Once you've done that, in your terminal ( not logged into the Homestead machine) run vagrant login and login with your details. 一旦你做到了这一点,在你的终端( 没有登录到宅基机)上运行vagrant login并使用您的信息登录。

Then run vagrant global-status to find the ID of the vagrant machine Homestead is running on. 然后运行vagrant global-status以查找Homestead正在运行的流浪机的ID。

Run vagrant share 123a4 (where 123a4 is the machine ID) and your machine will be shared! 运行vagrant share 123a4 (其中123a4是机器ID),您的机器将被共享!

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. 请注意,您可能必须设置Nginx配置以侦听为您生成的URL,以便它指向计算机上的正确站点。

Try this command in your homestead directory: vagrant provision 在宅基地目录中尝试此命令: vagrant provision

To get share URL use this command: vagrant share 要获取共享URL,请使用以下命令: vagrant share

Sometimes it doesn't worke on windows. 有时它不会在窗户上乱成一团。 Use vagrant share --http 8000 使用vagrant share --http 8000

8000 is port as homestead uses port forwarding 8000 -> 80 8000是端口,因为homestead使用端口转发8000 -> 80

Note: To use vagrant share you must have ngrok installed. 注意:要使用vagrant共享,必须安装ngrok

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM