centOS上编译和使用lantern科学上网

1.编译环境准备

需要预先安装的编译环境

  • Git - brew install git, apt-get install git, etc
  • Go 1.6 or higher.
  • GNU Make
  • Nodejs & NPM
  • GNU C Library (linux only) - apt-get install libc6-dev-i386, etc
  • Gulp npm i gulp-cli -g

1.1 安装git

[stefan@localhost conf]$ sudo yum install git

1.2 安装Go 1.6

下载Go的二进制安装包(如果打不开下载界面,可在windows翻墙下载,再上传至centOS),然后解压到安装目录

[stefan@localhost ~]$ go version
go: cannot find GOROOT directory: /usr/local/go

修改配置文件

[stefan@localhost ~]$ sudo vim /etc/profile

在最后添加如下两行

export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH

生效配置文件

[stefan@localhost ~]$ source /etc/profile

安装成功

[stefan@localhost ~]$ go version
go version go1.6.2 linux/amd64

1.3 安装make

可以使用yum安装,但make命令系统安装时已经装好了,可以检查一下

[root@localhost opt]# rpm -q make
make-3.82-21.el7.x86_64

1.4 安装 Nodejs & NPM

一定要切换到root用户执行:

[root@localhost opt]# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

然后用yum安装

[root@localhost opt]# yum -y install nodejs

检查是否安装成功

[root@localhost opt]# node --version
v6.2.1

由于新版的nodejs已经集成了npm,所以之前npm也一并安装好了。同样可以通过输入 “npm -v” 来测试是否成功安装

[root@localhost opt]# npm -v
3.9.3

1.5 安装GNU C Library

[stefan@localhost ~]$ sudo yum install glibc-devel.x86_64

1.6 安装Gulp

gulp 是基于 node 实现的,那么我们就需要先安装 node,npm 是 node 的包管理工具,可以利用它安装 gulp 所需的包,执行

[stefan@localhost lantern]$ sudo npm i gulp-cli -g

运行时注意查看命令行有没有错误信息,安装完成后,你可以使用下面的命令查看gulp的版本号以确保gulp已经被正确安装。

[root@localhost ~]# gulp -v
[21:58:10] CLI version 1.2.1

2. 开始编译lantern源码

/usr/local是小型应用软件的安装位置,相当于windows的program file

[stefan@localhost ~]$ cd /usr/local

执行下面的命令

[stefan@localhost local]$ sudo git clone https://github.com/getlantern/lantern.git

clone成功后,进入lantern源码包

[stefan@localhost local]$ cd lantern
[stefan@localhost lantern]$ ll
总用量 148
drwxr-xr-x. 2 root root  4096 6月  18 11:01 doc
-rw-r--r--. 1 root root  2733 6月  18 11:01 Dockerfile
-rw-r--r--. 1 root root   560 6月  18 11:01 envvars.bash.enc
drwxr-xr-x. 6 root root  4096 6月  18 11:01 installer-resources
drwxr-xr-x. 5 root root  4096 6月  18 11:01 LanternMobileTestbed
drwxr-xr-x. 8 root root  4096 6月  18 11:01 lantern-ui
-rw-r--r--. 1 root root 11363 6月  18 11:01 LICENSE
-rw-r--r--. 1 root root 30327 6月  18 11:01 Makefile
drwxr-xr-x. 5 root root  4096 6月  18 11:01 MobileSDK
-rwxr-xr-x. 1 root root   630 6月  18 11:01 pre-commit
-rwxr-xr-x. 1 root root  2001 6月  18 11:01 prehook.sh
-rwxr-xr-x. 1 root root   706 6月  18 11:01 pre-push
drwxr-xr-x. 5 root root  4096 6月  18 11:01 PubSub
drwxr-xr-x. 4 root root  4096 6月  18 11:01 pubsub-java
-rw-r--r--. 1 root root 13815 6月  18 11:01 README-dev.md
-rw-r--r--. 1 root root 10543 6月  18 11:01 README.md
-rw-r--r--. 1 root root  6768 6月  18 11:01 README-release.md
-rw-r--r--. 1 root root  1048 6月  18 11:01 README-translations.md
-rwxr-xr-x. 1 root root   118 6月  18 11:01 run.bash
-rwxr-xr-x. 1 root root   325 6月  18 11:01 setenv.bash
drwxr-xr-x. 7 root root  4096 6月  18 11:01 src
-rw-r--r--. 1 root root  1447 6月  18 11:01 testpackages.txt

开始编译

[stefan@localhost lantern]$ sudo make lantern

编译失败:

npm WARN lantern-ui@0.0.10-0 license should be a valid SPDX license expression
(node:20563) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[11:58:24] Using gulpfile /usr/local/lantern/lantern-ui/gulpfile.js
[11:58:24] Starting 'clean'...
[11:58:24] Starting 'usemin'...
(node:20563) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[11:58:24] Starting 'copy'...
[11:58:24] Finished 'copy' after 5.33 ms
[11:58:24] Finished 'clean' after 137 ms
[11:58:25] Finished 'usemin' after 1.27 s
[11:58:25] Starting 'build'...
[11:58:25] Finished 'build' after 2.77 μs
/usr/local/lantern
/bin/bash:行15: go: 未找到命令
make: *** [src/github.com/getlantern/flashlight/ui/resources.go] 错误 127

当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器