ngrok是一个ddns服务,为内网机器绑定一个公网域名,方便开发调试远程接口(如微信开发)。
之前博文里面写过如何安装ngrok,但是由于公司里面的研发工程师的笔记本有windows本和mac本,所以本次主要讲怎么生成windows、mac客户端。
准备工作:需要参考http://nanchunle.blog.51cto.com/9244770/1710295,安装完成ngrok
一、编译Windwos客户端
cd /usr/local/go/src
GOOS=windows GOARCH=amd64 ./make.bash
cd /usr/local/ngrok
GOOS=windows GOARCH=amd64 make release-client
#同理,这里的amd64是64位系统,32位改成386
#应该会在 bin/windows_amd64 目录下生成ngrok客户端程序
到这里,编译就完成了,就可以将ngrok.exe下载到windows操作系统。
启动步骤:
1、将ngrok.exe放在D:\ngrok,并且在D:\ngrok编辑配置文件ngrok.cfg
server_addr: "example.com:4443" |
2.打开windows控制台win+r ,进入D:\ngrok,执行
./ngrok -config=ngrok.cfg -log=ngrok.log -subdomain=test 8080 |
二、编译Mac客户端
cd /usr/local/go/src
GOOS=darwin GOARCH=amd64 ./make.bash
然后回去ngrok目录,接着编译:
cd /usr/local/src/ngrok
GOOS=darwin GOARCH=amd64 make release-client
完成后会在 /usr/local/src/ngrok/bin/darwin_amd64/ 下发现 ngrok 文件,将其拷贝到Mac上面,像上面windows
的设置即可使用。
三、注意事项
1、Centos/Linux下源码安装golang:
|
2、在步骤GOOS=darwin GOARCH=amd64 make release-client出现错误
imports runtime: C source files not allowed when not using cgo or SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_darwin.c mfixalloc.c mgc0.c mheap.c msize.c os_darwin.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c make: *** [deps] Error 1 |
解决方法:参考网站 http://stackoverflow.com/questions/27772831/golang-c-source-files-not-allowed-when-not-using-cgo
https://github.com/golang/go/wiki/InstallFromSource#introduction
Introduction This is a companion to http://golang.org/doc/install/source providing additional instructions for various operating systems. Install C toolsOn OS X, a C compiler is bundled in the command line tools for Xcode, and you don't need to install the whole Xcode to compile Go. If you have already installed Xcode 4.3+, you can install command line tools from the Components tab of the Downloads preferences panel. In more recent versions of Xcode, you can use command to install the command line tools without opening Xcode. To verify you have a working compiler, just invoke in a freshly created Terminal window, unless you see the error, you are ready to go. On Ubuntu/Debian, use . If you want to build 32-bit binaries on a 64-bit system you'll also need the package. On RedHat/Centos 6, use . If you want to build 32-bit binaries on a 64-bit system you'll need both and packages. |