安装git
1、安装git,我安装的是2.6版本,防止会出现另一个错误,安装git所需要的依赖包
yum -y install zlib-devel openssl-devel perl hg cpio expat-devel gettext-devel curl curl-devel perl-ExtUtils-MakeMaker hg wget gcc gcc-c++
2、下载git
wget https://www.kernel.org/pub/software/scm/git/git-2.6.0.tar.gz
3、解压git
tar zxvf git-2.6.0.tar.gz
4、编译gitk
cd git-2.6.0 ./configure --prefix=/usr/local/git make make install
5、创建git的软连接
ln -s /usr/local/git/bin/* /usr/bin/
_____________________________________________________ 安装go环境
准备go环境,我的系统是32位的centos所以我下载386的包
下载地址 http://www.golangtc.com/download
1、下载go的软件包
wget http://www.golangtc.com/static/go/go1.4.2/go1.4.2.linux-386.tar.gz wget http://www.golangtc.com/static/go/1.4.2/go1.4.2.linux-amd64.tar.gz
2、解压出来可以随便指定位置
tar zxvf go1.4.2.linux-386.tar.gz mv go /usr/local/
3、go的命令需要做软连接到/usr/bin
ln -s /usr/local/go/bin/* /usr/bin/
编译ngrok
cd /usr/local/ git clone https://github.com/inconshreveable/ngrok.git export GOPATH=/usr/local/ngrok/ export NGROK_DOMAIN="ngrok.域名.com" cd ngrok
为域名生成证书
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 server.key 2048 openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 5000
在软件源代码目录下面会生成一些证书文件,我们需要把这些文件拷贝到指定位置
cp rootCA.pem assets/client/tls/ngrokroot.crt cp server.crt assets/server/tls/snakeoil.crt cp server.key assets/server/tls/snakeoil.key
指定编译环境变量,如何确认GOOS和GOARCH,可以通过go env来查看
编译服务端
cd /usr/local/go/src GOOS=linux GOARCH=amd64 ./make.bash cd /usr/local/ngrok/ GOOS=linux GOARCH=amd64 make release-server
生产的在
/usr/local/ngrok/bin/windows_amd64/
scp ngrok.exe [email protected]地址:/www/web/
Windows的客户端编译
cd /usr/local/go/src GOOS=windows GOARCH=amd64 ./make.bash cd /usr/local/ngrok/ GOOS=windows GOARCH=amd64 make release-client
服务端启动
/usr/local/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":80"
/usr/local/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":80"
/usr/local/ngrok/bin/ngrokd -domain="域名.com" -httpAddr=":80"
可执行文件,这就是我们的服务端了,现在启动服务端试试:
/usr/local/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":8000"
______________ ps -A #找到PID kill -9 xxx __________ /usr/local/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":80"
-domain="$NGROK_DOMAIN" -httpAddr=":80"