搭建环境:阿里云Centos7
1、更新Git(高于1.7即可)
查看当前git版本:git --version
详见另一篇博客《
Linux安装最新版git》
2、安装go
CentOS7用户:
yum install -y mercurial git bzr subversion golang golang-pkg-windows-amd64 golang-pkg-windows-386
其他CentOS用户:
没有Go,只有虚拟机交叉编译,找台CentOS7的服务器编译GO。
检查Go安装成功与否
go version
3、下载ngrok
返回git的上层目录:cd ..
git clone https://github.com/inconshreveable/ngrok.git #不是所有者使用HTTPS方式或者SSH方式
如果报错
: git clone: fatal: Unable to find remote helper for 'https'
由于 Git configure 配置时没有设定 --with-curl --with-expat 造成
CentOS使用yum安装curl开发相关库后重新配置编译git即可:
命令:yum install libcurl-devel 随后cd到git目录make && make install等等...
4、生成自签名证书,在生成证书时需要一个解析到服务器上的主域名,以"zxfngrok.zxiaofan.com"为例:
cd ngrok
NGROK_DOMAIN="
zxfngrok.zxiaofan.com"
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000