Guacamole之本地安装Guacamole(二)

摘要

在网上看到一篇Guacamole官方手册的翻译,但是找不到后续,于是想自己也翻译几篇,有时间的话,会尽量多翻译一些。 原文地址:http://guacamole.incubator.apache.org/doc/gug/index.html

可本人安装配置总结后的步骤:http://www.cnblogs.com/ji-yun/p/4982498.html

Guacamole 分为两个部分:一部分是guacamole-server,它提供guacd 代理和关联包;另一部分是guacamole-client,它通过servlet容器在Tomcat上给客户端提供服务。

编译guacamole-server

       guacamole-server包含所有Guacamole连接远程桌面所需的本地、服务端组件。它还提供一个通用的C库——libguac、所有其它本地组建的依赖、以及为每个支持的协议单独的库和Guacamole的核心 guacd。,

      guacd是运行在Guacamole服务端上代理服务的守护进程,接收用户请求Guacamole web应用的隧道连接,然后代替用户连接远程桌面。编译guacd生成可执行文件,它可以手动执行,如果你愿意,也可以让它开机自启动。

      为了编译guacamole-server,你需要C编译器(例如:GCC)以及guacamole-server所依赖的库。一些依赖是必需的,还有一些是可选择的。但可选择的那些依赖可以增加一些额外的特性。

必需依赖

为了编译guacamole-server,你需要这些包:Cairo, libjpeg, libpng, and the OSSP UUID。这些包在任何情况下都是必须安装的,没有它们Guacamole就编译不了。

库名

特性

Cairo

Cairo 是被libguac 用来绘图的. 没有它Guacamole就实现不了此功能。

Debian / Ubuntu package

libcairo2-dev

Fedora / CentOS / RHEL package

cairo-devel

libjpeg-turbo

libjpeg-turbo 为libguac 提供 JPEG 的支持. 没有它Guacamole就无法编译。

Debian / Ubuntu package

libjpeg62-turbo-dev

Fedora / CentOS / RHEL package

libjpeg-turbo-devel

如果libjpeg-turbo 在你的平台上不可用, 并且你不希望用源码编译它, libjpeg 也会照常工作,只是速度不会那么快。

Debian / Ubuntu package

libjpeg62-dev

Fedora / CentOS / RHEL package

libjpeg-devel

libpng

libpng 被 libguac 用来写PNG 图像, 它是Guacamole 协议使用的核心图像类型. Guacamole 没有libpng就不能正常运转..

Debian / Ubuntu package

libpng12-dev

Fedora / CentOS / RHEL package

libpng-devel

OSSP UUID

OSSP UUID 被libguac 用来设计每一个Guacamole连接唯一的 ID. 这些唯一的ID是连接分享的基础。

Debian / Ubuntu package

libossp-uuid-dev

Fedora / CentOS / RHEL package

uuid-devel

可选择依赖

可选择性的依赖决定Guacamole哪些支持的协议会被安装,并且决定关于这些协议的额外特性是否可用。

Guacamole目前支持的协议有:VNC、RDP、SSH和telnet。每一种协议对应一个独立的库,如果你安装了它对应的依赖,这些独立的库就会随着guacamole-server被编译。

VNC的支持依赖于libvncclient,它是libVNCServer的一部分,RDP的支持依赖于FreeRDP 1.0或更高的版本,SSH的支持依赖于libssh2,telnet依赖于libtelnet。Pango是一个字体、文本布局库,为SSH和telnet提供支持。

Library name

Features

FreeRDP

FreeRDP is required for RDP support. If you do not wish to build RDP support, this library is not needed.

Debian / Ubuntu package

libfreerdp-dev

Fedora / CentOS / RHEL package

freerdp-devel

Pango

Pango is a text layout library which Guacamole's SSH and telnet support uses to render text. If you do not wish to build SSH or telnet support, this library is not needed.

Debian / Ubuntu package

libpango1.0-dev

Fedora / CentOS / RHEL package

pango-devel

libssh2

libssh2 is required for SSH support. If you do not wish to build SSH support, this library is not needed.

Debian / Ubuntu package

libssh2-1-dev

Fedora / CentOS / RHEL package

libssh2-devel

libtelnet

libtelnet is required for telnet support. If you do not wish to build telnet support, this library is not needed.

Debian / Ubuntu package

libtelnet-dev

Fedora / CentOS / RHEL package

libtelnet-devel

libVNCServer

libVNCServer provides libvncclient, which is required for VNC support. If you do not wish to build VNC support, this library is not needed.

Debian / Ubuntu package

libvncserver-dev

Fedora / CentOS / RHEL package

libvncserver-devel

PulseAudio

PulseAudio provides libpulse, which is used by Guacamole's VNC support to provide experimental audio support. If you are not going to be using the experimental audio support for VNC, you do not need this library.

Debian / Ubuntu package

libpulse-dev

Fedora / CentOS / RHEL package

pulseaudio-libs-devel

OpenSSL

OpenSSL provides support for SSL and TLS - two common encryption schemes that make up the majority of encrypted web traffic.

If you have libssl installed, guacd will be built with SSL support, allowing communication between the web application and guacd to be encrypted. This library is also required for SSH support for the sake of manipulating public/private keys.

Without SSL support, there will be no option to encrypt communication to guacd, and support for SSH cannot be built.

Debian / Ubuntu package

libssl-dev

Fedora / CentOS / RHEL package

openssl-devel

libvorbis

libvorbis provides support for Ogg Vorbis - a free and open standard for sound compression. If installed, libguac will be built with support for Ogg Vorbis, and protocols supporting audio will use Ogg Vorbis compression when possible.

Otherwise, sound will only be encoded as WAV (uncompressed), and will only be available if your browser also supports WAV.

Debian / Ubuntu package

libvorbis-dev

Fedora / CentOS / RHEL package

libvorbis-devel

libwebp

libwebp is used by libguac to write WebP images. Though support for WebP is not mandated by the Guacamole protocol, WebP images will be used if supported by both the browser and by libguac.

Lacking WebP support, Guacamole will simply use JPEG in cases that it would have preferred WebP.

Debian / Ubuntu package

libwebp-dev

Fedora / CentOS / RHEL package

libwebp-devel

获取源代码

      你可以在Guacamole的项目网站上获取一份guacamole-server 源码。最新的稳定发行版是经过了Guacamole小组的测试,认为适合公众使用的版本。从项目网站上下载的.tar.gz格式压缩包,可以用过下列命令解压:

$ git clone git://github.com/glyptodon/guacamole-server.git
Cloning into 'guacamole-server'...
remote: Counting objects: 6769, done.
remote: Compressing objects: 100% (2244/2244), done.
remote: Total 6769 (delta 3058), reused 6718 (delta 3008)
Receiving objects: 100% (6769/6769), 2.32 MiB | 777 KiB/s, done.
Resolving deltas: 100% (3058/3058), done.
$

如果你想得到最新的代码,并且不关心它没有经过稳定发行版一样严格的测试,你也可以用Guacamole团队在Github上的仓库里克隆一份:

$ git clone git://github.com/glyptodon/guacamole-server.git
Cloning into 'guacamole-server'...
remote: Counting objects: 6769, done.
remote: Compressing objects: 100% (2244/2244), done.
remote: Total 6769 (delta 3058), reused 6718 (delta 3008)
Receiving objects: 100% (6769/6769), 2.32 MiB | 777 KiB/s, done.
Resolving deltas: 100% (3058/3058), done.
$

编译流程

      当你把guacamole-server源码下载下来,并且解压后,就可以运行configure命令。这是一个被GNU Autotools自动触发的shell脚本,GNU Autotools是一种流行的编译系统,也被Guacamole 所使用。正在运行的configure 命令会判断哪些库在你的系统上有效,并且会根据你所安装的依赖选择合适的组件来编译。                       

 

注意:如果是直接从git上下载的源码,并不包含configure脚本,因此自动生成源码没有包含在工程仓库中。如果你是从git仓库中直接下载的源码,就需要手动生成configure

$ cd guacamole-server/

$ autoreconf -fi

$

执行上面的命令会安装GNU Autotools。

从项目官网上下载的源代码文档包含configure脚本和所有其它编译所需要的文件,因此在编译的机器上不需要安装GNU Autotools。

 

一旦你运行了configure 命令,你就能看到已经安装的库的列表,它会决定你哪些功能会被编译:

$ ./configure --with-init-dir=/etc/init.d
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
...

------------------------------------------------
guacamole-server version 0.9.9
------------------------------------------------

   Library status:

     freerdp ............. yes
     pango ............... yes
     libssh2 ............. yes
     libssl .............. yes
     libtelnet ........... yes
     libVNCServer ........ yes
     libvorbis ........... yes
     libpulse ............ yes
     libwebp ............. yes

   Protocol support:

      RDP ....... yes
      SSH ....... yes
      Telnet .... yes
      VNC ....... yes

   Init scripts: /etc/init.d

Type "make" to compile guacamole-server.

$

上面显示的--with-init-dir=/etc/init.d命令,为guacd 安装启动脚本到/etc/init.d目录,这样我们就很容易的在系统启动后自动运行guacd 配置脚本。如果你不希望guacd 开机自启动,就去掉 --with-init-dir选项。如果包含你系统发行版的启动脚本不同于/etc/init.d目录,就需要用正确的路径代替/etc/init.d。你也许需要查询你发行版的文档,或者对/etc做一个小调查来决定正确的位置。

 

在这里,configure 命令会找到所有的可选择的依赖包,并根据所安装的依赖包来编译所支持的所有协议,甚至在RDP协议下支持Ogg Vorbis 声音。如果你缺失一些包,上面显示“yes”的结果会变成“no”。如果一个必需包缺失了,脚本将会彻底运行失败,并且你需要安装所缺失的依赖。如果在运行configure 命令后,你发现你想要的一些功能没有被支持,你就需要安装相应的依赖并且再运行一次configure 命令。

 

注意:SSH和telnet的正常支持都需要安装了相应的字体,否则输出到终端的内容将不能呈现出来。所需要的字体没有安装,也照样会编译对SHH和telnet的支持,但是在连接的时候会失败:

Aug 23 14:09:45 my-server guacd[5606]: Unable to get font "monospace"

如果SHH或telnet连接没有正常工作,你会在系统日志里看到这样的信息,安装字体,再次尝试连接。

 

一旦configure 命令执行完成,只需要键入”make”, guacamole-server就会开始编译:

$ make
Making all in src/libguac
make[1]: Entering directory `/home/zhz/guacamole/guacamole-server/src/libguac'
...
make[1]: Leaving directory `/home/zhz/guacamole/guacamole-server/src/protocols/vnc'
make[1]: Entering directory `/home/zhz/guacamole/guacamole-server'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/zhz/guacamole/guacamole-server'
$

在编译所有的组建时,有大量的输出信息滚动屏幕。

安装

当以上所有的都完成时,你只需要输入“make install”来安装编译好的组建,然后输入“ldconfig”来更新你系统安装库的缓存:

# make install
Making install in src/libguac
make[1]: Entering directory `/home/zhz/guacamole/guacamole-server/src/libguac'
make[2]: Entering directory `/home/zhz/guacamole/guacamole-server/src/libguac'
...
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/zhz/guacamole/guacamole-server/src/protocols/vnc'
make[1]: Leaving directory `/home/zhz/guacamole/guacamole-server/src/protocols/vnc'
make[1]: Entering directory `/home/zhz/guacamole/guacamole-server'
make[2]: Entering directory `/home/zhz/guacamole/guacamole-server'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/zhz/guacamole/guacamole-server'
make[1]: Leaving directory `/home/zhz/guacamole/guacamole-server'
# ldconfig
#   

这时候,所有的都安装好了,但guacd并没有运行起来。使用Guacamole 还需要把客户端组建也安装好再运行guacd。

注意在安装guacd和它的自启动脚本后,你可能仍然需要激活服务来运行自启动。自启动的方式因不同发行版系统而不同,但是每一个发行版都会有它的文档描述如何设置自启动。

guacamole-client

注意:一般而言,你不需要编译guacamole-client,因为它是用Java写的交互平台。你能很轻松的在Guacamole项目官网上获取最新版本的guacamole-client,包括所有的支持的扩展,不需要你自己编译。

如果你不想自己用源码编译guacamole-client,就直接从项目官网下载guacamole.war,以及任何所需要的扩展,就可以直接跳到“部署Guacamole”部分。

 

guacamole-client包含Guacamole的所有Java和JavaScript组建(guacamole、guacamole-common、guacamole-ext、guacamole-common-js)。这些组建最终组成web应用,为用户提供HTML5 Guacamole 客户端服务来连接服务端。该web应用会连接guacamole-server的一部分guacd,来代表用户连接任何远程桌面服务,使用户有权限访问它。

为了编译guacamole-client,你还需要安装Apache Maven和Java JDK。但不是所有人都需要,有的linux发行版已经为你安装可这些包。

你可以从Guacamole项目的官网上获取guacamole-client源码的一个副本。这些发行版是最新代码的稳定的快照,经过了Guacamole小组的测试,认为适合公众使用的版本。从项目网站上下载的.tar.gz格式压缩包,可以用过下列命令解压:

$ tar -xzf guacamole-client-0.9.9.tar.gz
$ cd guacamole-client-0.9.9/
$

和guacamole-server一样,如果你想得到最新的代码,并且不关心它没有经过稳定发行版一样严格的测试,你也可以用Guacamole团队在Github上的仓库里克隆一份:

$ git clone git://github.com/glyptodon/guacamole-client.git
Cloning into 'guacamole-client'...
remote: Counting objects: 12788, done.
remote: Compressing objects: 100% (4183/4183), done.
remote: Total 12788 (delta 3942), reused 12667 (delta 3822)
Receiving objects: 100% (12788/12788), 3.23 MiB | 799 KiB/s, done.
Resolving deltas: 100% (3942/3942), done.
$

不像guacamole-server的是,即使你从git仓库里获取了源码,你也不需要再编译的时候运行任何程序。在编译之前不需要运行任何脚本,在源码中提供了Maven需要的pom.xml文件。

编译guacamole-client,仅仅需要运行"mvn package"。它会请求Maven自动编译和打包所有的组建,生成一个简单的.war文件,它包含了web整个应用。

$ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] guacamole-common
[INFO] guacamole-ext
[INFO] guacamole-common-js
[INFO] guacamole
[INFO] guacamole-auth-jdbc
[INFO] guacamole-auth-jdbc-base
[INFO] guacamole-auth-jdbc-mysql
[INFO] guacamole-auth-jdbc-postgresql
[INFO] guacamole-auth-ldap
[INFO] guacamole-auth-noauth
[INFO] guacamole-client
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] guacamole-common ................................... SUCCESS [  7.566 s]
[INFO] guacamole-ext ...................................... SUCCESS [  5.594 s]
[INFO] guacamole-common-js ................................ SUCCESS [  1.249 s]
[INFO] guacamole .......................................... SUCCESS [  8.474 s]
[INFO] guacamole-auth-jdbc ................................ SUCCESS [  0.592 s]
[INFO] guacamole-auth-jdbc-base ........................... SUCCESS [  2.548 s]
[INFO] guacamole-auth-jdbc-mysql .......................... SUCCESS [  2.557 s]
[INFO] guacamole-auth-jdbc-postgresql ..................... SUCCESS [  1.990 s]
[INFO] guacamole-auth-ldap ................................ SUCCESS [  1.314 s]
[INFO] guacamole-auth-noauth .............................. SUCCESS [  0.961 s]
[INFO] guacamole-client ................................... SUCCESS [  1.721 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.701 s
[INFO] Finished at: 2015-06-08T17:03:15-07:00
[INFO] Final Memory: 34M/340M
[INFO] ------------------------------------------------------------------------
$

当Guacamole web应用编译完成,在当前目录(你运行mvn时的目录)的子目录guacamole/target/ 中就会生成一个.war文件,然后可以发布到一个servlet容器中,例如:Tomcat。

部署Guacamole

Guacamole的web应用部分,是被打包成一个完全独立的 .war文件。如果你从项目官网下载Guacamole,文件名为 guacamole.war。部署这个文件到你的servlet容器使用.war的目录中。在Tomcat环境中,这个目录是CATALINA_HOME/webapps/。这个路径CATALINA_HOME会因你的Tomcat是如何装的而变化,但通常是类似于/var/lib/tomcat/var/lib/tomcat7

# cp guacamole.war /var/lib/tomcat/webapps
#

如果你是从源码编译的guacamole-client,所需的.war就在guacamole/target/目录中,并且它的名字会包含一个额外的版本后缀。如Tomcat会根据.war文件来确定web应用程序的路径,你可以在复制的时候重命名这个文件为guacamole.war:

#cp guacamole/target/guacamole-0.9.9.war  /var/lib/tomcat/webapps/guacamole.war
#

另外,如果你用的不同的servlet容器或者Tomcat安装在不同的路径中,你就需要去查看servlet容器或系统发行版的文档,或者两者共同决定部署.war文件的路径,例如:guacamole.war。

一旦.war文件放在了正确的路径下,你就需要重启Tomcat来强制Tomcat部署新的web应用程序,并且如果guacd守护进程不是一直保持运行,也必须重启。在不同的发行版中,重启Tomcat和guacd的命令也会不同。典型的,你能通过运行相应的初始化脚本来重启:

# /etc/init.d/tomcat7 restart
Stopping Tomcat... OK
Starting Tomcat... OK
# /etc/init.d/guacd start
Starting guacd: SUCCESS
guacd[6229]: INFO:  Guacamole proxy daemon (guacd) version 0.9.9 started
#

注意:如果你想要开机启动Guacamole,就需要配置Tomcat和guacd自启动。你的发行版会提供文档来做这个。

 

在重启Tomcat并且启动guacd之后,Guacamole就成功的安装好了,即使它没有完全的运行。在目前的状态,它还完全没有配置,下一步就是至少为添加一个用户,和一些连接。具体请看:Guacamole之配置Guacamole(五)《Chapter 5, Configuring Guacamole.》。

客户端如何发送消息?

如果你的浏览器和servlet容器支持,Guacamole就会自动使用网络套接字。在Guacamole不能用网络套接字连接时,它会立刻向用户透明的回退使用HTTP。

在Guacamole中网络套接字能被Tomcat7.0.37或更高的版本、Jetty8或更高版本支持,并且任何servlet容器都支持JSR 256,这是Java API对网络套接字的标准。

 

posted @ 2016-07-21 20:45  积蕴  阅读(10071)  评论(20编辑  收藏  举报