我正在尝试通过ngrok公开我的本地服务器。我正在使用vagrant在本地服务器上运行项目,因此,我读到有一个vagrant和ngrok的插件,“ vagrant share”。我已经下载了ngrok,但是当我运行命令vagrant share时,结果就是这样:
找不到可执行文件'ngrok'Vagrant正在尝试运行 在PATH变量中。需要'ngrok'可执行文件才能 运行流浪者共享。如果“ ngrok”当前安装在 非标准位置,将该位置附加到PATH 变量,然后再次运行此命令。
我已经将ngrok放入环境变量中,但是它不起作用。
任何想法如何解决?我有几天的时间无法解决这个问题。
答案 0 :(得分:0)
您是否尝试过手动安装vagrant share
插件?
vagrant plugin install vagrant-share
答案 1 :(得分:0)
你必须在你的 Windows PATH 中明确有 ngrok。我怀疑 vagrant share
插件没有安装 ngrok
。
为了给自己做同样的事情,我碰巧在运行 Visual Studio Code,使用 PowerShell 作为终端。我从 ngrok 网站下载了 zip 格式的 ngrok,将其解压缩,放在我的 Windows 主目录中,然后将其添加到 PowerShell 路径中。然后 vagrant share
立即起作用(我不必明确设置身份验证令牌或连接帐户)。下面将 windowsuser
替换为您的帐户 ID。
c:\Users\windowsuser
$env:Path += ";c:\users\windowsuser"
PS C:\Users\windowsuser\vagrant_getting_started> ngrok
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
DESCRIPTION:
ngrok exposes local networked services behinds NATs and firewalls to the
public internet over a secure tunnel. Share local websites, build/test
webhook consumers and self-host personal services.
Detailed help for each command is available with 'ngrok help <command>'.
Open http://localhost:4040 for ngrok's web interface to inspect traffic.
EXAMPLES:
ngrok http 80 # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080 # port 8080 available at baz.ngrok.io
ngrok http foo.dev:80 # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls -hostname=foo.com 443 # TLS traffic for foo.com to port 443
ngrok start foo bar baz # start tunnels from the configuration file
VERSION:
2.3.35
AUTHOR:
inconshreveable - <alan@ngrok.com>
COMMANDS:
authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command
PS C:\Users\windowsuser\vagrant_getting_started>
vagrant share
应该可以工作;如您所见,我正在学习 vagrant 教程。PS C:\Users\windowsuser\vagrant_getting_started> vagrant share
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
default: Local HTTP port: 4567
default: Local HTTPS port: disabled
default: Port: 2200
default: Port: 4567
==> default: Creating Vagrant Share session...
==> default: HTTP URL: http://e058e1d1b464.ngrok.io
==> default:
C:\Users\windowsuser>set PATH=%PATH%;C:\Users\windowsuser