-bash: ngrok: 命令未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26452816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
-bash: ngrok: command not found
提问by Lauren F
I'm trying to integrate the Twilio API into my Rails app. The tutorial I found suggested using ngrok to put my app on the internet (rather than working on localhost). I've installed and upnzipped ngrok, and when I try to call it from the directory it is in, I get:
我正在尝试将 Twilio API 集成到我的 Rails 应用程序中。我发现的教程建议使用 ngrok 将我的应用程序放在互联网上(而不是在本地主机上工作)。我已经安装并压缩了 ngrok,当我尝试从它所在的目录调用它时,我得到:
-bash: ngrok: command not found.
Does anyone know what my problem might be? Also could anyone explain what ngrok does vs deploying to heroku? If heroku would work the same, I would just do that. I'm new to using APIs, though, so I'm not clear on why I'm using ngrok.
有谁知道我的问题可能是什么?也有人可以解释 ngrok 与部署到 heroku 的区别吗?如果 heroku 也能正常工作,我会这样做。不过,我是使用 API 的新手,所以我不清楚为什么要使用 ngrok。
Thanks!
谢谢!
回答by Rambo Ramon
If the binary is not located in one of the folders stored in the environment variable $PATH you have to provide at least a relative path to your current location. So if you are in the same folder as the binary then you have to call it with ./ngrok
如果二进制文件不在环境变量 $PATH 中存储的文件夹之一中,则必须至少提供一个到当前位置的相对路径。因此,如果您与二进制文件位于同一文件夹中,则必须使用./ngrok
回答by lacostenycoder
To access from any directory I had to move the binary to $PATH
要从任何目录访问,我必须将二进制文件移动到 $PATH
mv ngrok /usr/local/bin
in order to call executable from everywhere.
为了从任何地方调用可执行文件。
UPDATE: brew install ngrok
no longer works because:
更新:brew install ngrok
不再有效,因为:
Error: No available formula with the name "ngrok"
Upstream sunsetted 1.x in March 2016 and 2.x is not open-source.
So you'll need to download binary from https://ngrok.com/download
所以你需要从https://ngrok.com/download下载二进制文件
As for question "What does ngrok do vs Heroku?", ngrok is totally different than Heroku, which is more complex. Ngrok allows you to expose a running local server over the internet using a secure tunnel. Heroku is a cloud hosting platform for web applications. To use ngrok you can just run your local server and expose it via ngrok. Anyone who connects via ngrok to your server is actually communicating to a server running you YOUR local machine. With Heroku, your application is running on hosted virtual machines in the cloud. That is an oversimplification, but in short, NGROk is good for very fast testing of your server by some remote users. It can also be useful for transferring files / data etc. from inside a virtualized environment i.e. a cloud ssh session.
至于“ngrok 与 Heroku 的区别是什么?”,ngrok 与 Heroku 完全不同,后者更为复杂。Ngrok 允许您使用安全隧道通过 Internet 公开正在运行的本地服务器。Heroku 是一个用于 Web 应用程序的云托管平台。要使用 ngrok,您只需运行本地服务器并通过 ngrok 公开它。通过 ngrok 连接到您的服务器的任何人实际上都在与运行您本地机器的服务器通信。使用 Heroku,您的应用程序可以在云中托管的虚拟机上运行。这是一种过度简化,但简而言之,NGROk 非常适合某些远程用户对您的服务器进行非常快速的测试。它也可用于从虚拟化环境(即云 ssh 会话)内部传输文件/数据等。
回答by rachelzuzu
the command has changed to: ngrok http 80
命令已更改为:ngrok http 80
Examples from ngrok:
来自 ngrok 的例子:
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 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
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 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