需要軟件依賴:
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++
安裝git:
yum -y install git
下載與安裝go語言:
http://www.golangtc.com/download
我下載得是:
go1.7.4.linux-amd64.tar.gz
////////////////
解壓:
tar -zxvf go1.4.2.linux-386.tar.gz
mv?go?/usr/local/
制作go語言命令軟連接:
ln -s /usr/local/go/bin/* /usr/bin/
////////////////////
使用git克隆ngrok項(xiàng)目
cd /usr/local/
git?clone?https://github.com/inconshreveable/ngrok.git
////////////////////
編譯ngrok前得準(zhǔn)備:
cd ngrok
export GOPATH=/usr/local/ngrok/
export?NGROK_DOMAIN="ngrok.gamecc.cn"
這里得NGROK_DOMAIN請(qǐng)?jiān)O(shè)置為自己得主機(jī)地址(域名)
為域名生成證書:
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
上面得$NGROK_DOMAIN其實(shí)是剛才export得環(huán)境變量鳞青,我們?nèi)绻謩?dòng)輸入得話也行。那么上面得export NGROK_DOMAIN="xxx.xxx.xxx"則無需設(shè)置为朋。
拷貝證書到指定位置:
cp rootCA.pem assets/client/tls/ngrokroot.crt
cp?server.crt?assets/server/tls/snakeoil.crt
cp?server.key?assets/server/tls/snakeoil.key
修改logger.go源代碼胶惰,天朝得服務(wù)器需要修改,香港或則美國(guó)的主機(jī)可以忽略這一步:
vim /usr/local/ngrok/src/ngrok/log/logger.go
log?"github.com/keepeye/log4go"
/////////////////////////////////////////////////////////////////////////
開始編譯:
指定編譯環(huán)境變量
cd/usr/local/go/src
GOOS=linux GOARCH=amd64 make
這里的amd64是代表英特爾或者amd的64位cpu架構(gòu)(因?yàn)閍md64架構(gòu)率先推出桌面版的64位cpu霞溪,所以在linux中孵滞,為了紀(jì)念這個(gè)事情,桌面級(jí)別的64bit架構(gòu)cpu都使用這個(gè)amd64代號(hào)加以說明)
編譯ngrok服務(wù)器端
cd/usr/local/ngrok
GOOS=linux GOARCH=amd64 make release-server
編譯ngrok客戶端
GOOS=linux GOARCH=amd64 make release-client
編譯windows系統(tǒng)版本的客戶端
GOOS=windows GOARCH=amd64 make release-client