设为首页 收藏本站
查看: 1028|回复: 0

[经验分享] 编译ngrok的Windows、Mac的客户端

[复制链接]

尚未签到

发表于 2018-6-15 09:06:00 | 显示全部楼层 |阅读模式
  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客户端程序
DSC0000.png

  到这里,编译就完成了,就可以将ngrok.exe下载到windows操作系统。
  启动步骤:
  1、将ngrok.exe放在D:\ngrok,并且在D:\ngrok编辑配置文件ngrok.cfg
server_addr: "example.com:4443"  trust_host_root_certs: false
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>  完成后会在 /usr/local/src/ngrok/bin/darwin_amd64/ 下发现 ngrok 文件,将其拷贝到Mac上面,像上面windows
  的设置即可使用。
  三、注意事项
  1、Centos/Linux下源码安装golang:

  •   wget https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz
  •   tar -C /usr/local -xzf go1.4.1.linux-amd64.tar.gz
  •   mkdir $HOME/go
  •   echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
  •   echo 'export GOPATH=$HOME/go' >> ~/.bashrc
  •   echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc
  •   source $HOME/.bashrc

  2、在步骤GOOS=darwin GOARCH=amd64 make>  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 tools
  On 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 xcode-select --install command to install the command line tools without opening Xcode. To verify you have a working compiler, just invoke gcc in a freshly created Terminal window, unless you see the "gcc: command not found" error, you are ready to go.
  On Ubuntu/Debian, use sudo apt-get install gcc libc6-dev. If you want to build 32-bit binaries on a 64-bit system you'll also need the libc6-dev-i386 package.
  On RedHat/Centos 6, use sudo yum install gcc glibc-devel. If you want to build 32-bit binaries on a 64-bit system you'll need both glibc-devel.i386 and glibc-devel.x86_64 packages.
  On Windows, install gcc with TDM-GCC. (Make sure you add its bin subdirectory to your PATH.) Go does not support the Cygwin toolchain.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-524005-1-1.html 上篇帖子: Windows 7 之无线唤醒电脑(Wake On Wlan) 下篇帖子: WINDOWS中cmd的切换目录cd命令失效
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表