Skip to content

Commit

Permalink
README.md update
Browse files Browse the repository at this point in the history
  • Loading branch information
bovinphang committed Oct 17, 2017
1 parent af4b938 commit 415003a
Showing 1 changed file with 197 additions and 33 deletions.
230 changes: 197 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,10 @@ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64/jr
[root@localhost git-1.9.0]# make install
[root@localhost git-1.9.0]# git --version #测试git是否安装成功
```
添加git的环境变量
添加git到环境变量
```shell
[root@localhost src]# vi /etc/profile
```
在最后加上如下一行代码:
将其打开把:
```shell
export PATH=$PATH:/usr/local/git/bin:/usr/local/git/libexec/git-core
Expand All @@ -200,77 +199,242 @@ export PATH=$PATH:/usr/local/git/bin:/usr/local/git/libexec/git-core
```shell
[root@localhost src]# git clone https://github.com/webrtc/apprtc.git
[root@localhost src]# cd apprtc
[root@localhost src]# npm install
[root@localhost apprtc]# npm install
```

##### 构建Apprtc项目:

```shell
[root@localhost apprtc]# grunt build
```

常见错误:requests模块不存在

```shell
Running "shell:buildAppEnginePackage" (shell) task
Traceback (most recent call last):
File "./build/build_app_engine_package.py", line 12, in <module>
import requests
ImportError: No module named requests
Warning: Command failed: python ./build/build_app_engine_package.py src out/app_engine
Traceback (most recent call last):
File "./build/build_app_engine_package.py", line 12, in <module>
import requests
ImportError: No module named requests
Use --force to continue.

Aborted due to warnings.
```

解决方法:通过python的包管理工具pip来安装requests

##### 安装pip

pip类似RedHat里面的yum,安装Python包非常方便。

1. 下载并安装setuptools:
```shell
[root@localhost src]# wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
[root@localhost src]# python ez_setup.py --insecure
```
2. 安装pip:
[python官网](https://pypi.python.org/pypi/pip)下载pip安装包安装

```shell
[root@localhost src]# wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
[root@localhost src]# tar -zxvf pip-9.0.1.tar.gz
[root@localhost src]# cd pip-9.0.1
[root@localhost pip-9.0.1]# sudo python setup.py install
[root@localhost pip-9.0.1]# pip -V #测试pip是否安装成功
```

##### 安装requests模块

```shell
[root@localhost src]# pip install requests
```

##### 再次构建Apprtc项目:

```shell
[root@localhost src]# cd apprtc
[root@localhost apprtc]# grunt build
```

##### 运行Apprtc

```shell
[root@localhost src]# dev_appserver.py /usr/local/src/apprtc/src/app_engine
```

dev_appserver.py 是/usr/local/google_appengine目录下的文件,已经配置在环境变量中。

如果要外网访问,加上host和端口,如:dev_appserver.py --host 121.40.28.178 --port 80 --admin_host 121.40.28.178 /usr/local/src/apprtc/src/app_engine

参照上面的配置,在浏览器中打开http://121.40.28.178即可访问

注:需检查80、8080和8000端口是否已开启,若未开启,则开启之:

```shell
[root@localhost src]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@localhost src]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
[root@localhost src]# firewall-cmd --zone=public --add-port=8000/tcp --permanent
[root@localhost src]# firewall-cmd --reload #重启防火墙,使开启的端口生效
[root@localhost src]# firewall-cmd --permanent --query-port=80/tcp #查询是否已开启的80端口
```

## 八、安装Collider

Collider是Google Chrome WebRTC项目里提供的用GO语言编写的基于WebSocket的信令服务器,也是Apprtc这个项目配套的一个信令服务器。在我们的Apprtc项目中就已经携带了它的源码。在安装collider之前,我们必须先安装Golang。

##### 安装Golang

go标准包安装:

# Collider
```
[root@localhost src]# wget https://studygolang.com/dl/golang/go1.9.1.linux-amd64.tar.gz
[root@localhost src]# tar -zxvf go1.9.1.linux-amd64.tar.gz -C /usr/local
[root@localhost src]# mkdir -p /usr/local/gopath
```

A websocket-based signaling server in Go.
添加go到环境变量:

## Building
```shell
[root@localhost src]# vi /etc/profile
```

1. Install the Go tools and workspaces as documented at http://golang.org/doc/install and http://golang.org/doc/code.html
将其打开把:

2. Checkout the `apprtc` repository
```shell
export GOROOT=/usr/local/go
export GOPATH=/usr/local/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
```

这句放在“export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC”的上一行。
立即生效环境配置,不需要重启,用下命令:

```shell
[root@localhost src]# . /etc/profile
[root@localhost src]# go version #测试go是否安装成功
```

注:GOPATH环境变量用来指定你的工作目录。当我们在开发Golang项目的时候需要指定

> The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code.
> GOPATH环境变量用来指定除GOROOT之外包含的Go项目源代码和二进制文件的目录。go install和go工具都会用到GOPATH,作为编译后二进制文件的存放目的地和import包时的搜索路径。
GOPATH是一个路径列表,也就是可以同时指定多个目录。多个目录在Mac和Linux下通过”:”分割;Windows下通过”;”分割。注意,大部分情况下会是第一个路径优先。

$GOPATH 目录约定有三个子目录:

- src 存放源代码(比如:.go .c .h .s等)
- pkg 编译后生成的文件(比如:.a)
- bin 编译后生成的可执行文件(为了方便,可以把此目录加入到 $PATH 变量中,如果有多个gopath,那么使用${GOPATH//://bin:}/bin添加所有的bin目录)

或yum安装:

```shell
[root@localhost src]# yum remove golang
[root@localhost src]# yum -y install golang
[root@localhost src]# go version #测试go是否安装成功
```

##### 构建

1. Checkout `apprtc`

```shell
[root@localhost src]# git clone https://github.com/webrtc/apprtc.git
```
git clone https://github.com/webrtc/apprtc.git

2. 创建 $GOPATH 的src目录

E.g.

```shell
[root@localhost src]# export GOPATH=/usr/local/gopath
[root@localhost src]# mkdir $GOPATH/src
```

3. Make sure to set the $GOPATH according to the Go instructions in step 1
3. 将collider的源码目录链接到 `$GOPATH/src`

E.g. `export GOPATH=$HOME/goWorkspace/`
`mkdir $GOPATH/src`
```shell
[root@localhost src]# ln -s /usr/local/src/apprtc/src/collider/collider $GOPATH/src
[root@localhost src]# ln -s /usr/local/src/apprtc/src/collider/collidermain $GOPATH/src
[root@localhost src]# ln -s /usr/local/src/apprtc/src/collider/collidertest $GOPATH/src
```

4. Link the collider directories into `$GOPATH/src`
4. 安装collidermain项目依赖

```shell
[root@localhost src]# go get -v collidermain
```
ln -s `pwd`/apprtc/src/collider/collider $GOPATH/src
ln -s `pwd`/apprtc/src/collider/collidermain $GOPATH/src
ln -s `pwd`/apprtc/src/collider/collidertest $GOPATH/src
报错:
```shell
Fetching https://golang.org/x/net/websocket?go-get=1
https fetch failed: Get https://golang.org/x/net/websocket?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
package golang.org/x/net/websocket: unrecognized import path "golang.org/x/net/websocket" (https fetch: Get https://golang.org/x/net/websocket?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
```
原因:因为golang.org被墙,国内使用 go get 安装 golang 官方包会失败。

5. Install dependencies
不翻墙的情况下怎么解决这个问题?其实 golang 在 github 上建立了一个[镜像库](https://github.com/golang),如 <https://github.com/golang/net> 即是 <https://golang.org/x/net> 的镜像库。

获取 golang.org/x/net 包,其实只需要以下步骤:

```shell
[root@localhost src]# mkdir -p $GOPATH/src/golang.org/x
[root@localhost src]# cd $GOPATH/src/golang.org/x
[root@localhost src]# git clone https://github.com/golang/net.git
[root@localhost src]# go install net
```
go get collidermain
```

6. Install `collidermain`
安装其它依赖类似。

如果上面命令仍失败,那么则可用下面这个麻烦的方法安装GO环境的websocket包:

```shell
[root@localhost src]# cd $GOPATH/src
[root@localhost src]# wget http://www.golangtc.com/static/download/packages/golang.org.x.net.tar.gz
[root@localhost src]# tar -zxvf golang.org.x.net.tar.gz
[root@localhost src]# go install golang.org/x/net/websocket/
```
go install collidermain

这样collidermain的项目依赖就安装完了。

5. 安装 `collidermain`

```shell
[root@localhost src]# go install collidermain
[root@localhost src]# collidermain --help #测试collidermain是否安装成功
```

## Running
##### 运行(启动colider)

```
$GOPATH/bin/collidermain -port=8089 -tls=true
```shell
[root@localhost src]# $GOPATH/bin/collidermain -port=8089 -tls=true
```

## Testing
##### 测试

```
go test collider
```shell
[root@localhost src]# go test collider
```

## Deployment
##### 部署

These instructions assume you are using Debian 7/8 and Go 1.6.3.
1. 修改房间服务器IP。即修改 [roomSrv](https://github.com/webrtc/apprtc/blob/master/src/collider/collidermain/main.go#L16) 为 你的apprtc服务器实例, e.g.

1. Change [roomSrv](https://github.com/webrtc/apprtc/blob/master/src/collider/collidermain/main.go#L16) to your AppRTC server instance e.g.
```shell
[root@localhost src]# vi /usr/local/src/apprtc/src/collider/collidermain/main.go
```

找开修改下面一行

```go
var roomSrv = flag.String("room-server", "https://your.apprtc.server", "The origin of the room server")
var roomSrv = flag.String("room-server", "https://192.168.9.223", "The origin of the room server")
```

1. Then repeat step 6 in the Building section.
2. 然后重复上面构建部分的步骤5。

### Install Collider

Expand Down

0 comments on commit 415003a

Please sign in to comment.