SHINY-SERVER R(sparkR)语言web解决方案 架设shiny服务器

1. shiny server简介

shiny-server是一种可用把R 语言以web形式展示的服务,其实RStudio公司自己构建了R Shiny Application运行的平台(http://www.shinyapps.io/ ), 用户可以通过RStudio上面的工具把自己编写调试好的Shiny Application上传到shinyapps.io上去(这里需要先注册和设置些东西)。这样构建了一个云端的服务器。但是有时还是有必要自己去构建一个自己的Shiny 服务器,这样操作起来还是方便些。下面就讲讲如何在自己的服务器上构建Shiny Server。

环境:ubuntu14.04

下载:shiny-server的地址

 

2. 安装步骤

2.1  安装libpng,x11相关支持包

由于ubuntu默认是不支持png 以及X11(redhat,centos也会有同样的问题)

所以安装R语言前需要安装libpng,x11相关包,命令如下

bonnie@bonnie0:~$ sudo apt-get install build-essential gcc g++ autoconf libiconv-hook-dev libmcrypt-dev libxml2-dev libmysqlclient-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libfreetype6-dev

bonnie@bonnie0:~$ sudo apt-get install libX11-dev libXext-dev libXtst-dev libXrender-dev libxmu-dev libxmuu-dev

2.2 安装R语言 验证X11 ,libpng支持

 

bonnie@bonnie0:~$ sudo apt-get install r-base

在命令行输入R进入R语言shell

bonnie@bonnie0: R

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets
    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE     TRUE     TRUE
  libxml     fifo   cledit    iconv      NLS  profmem    cairo
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE

PS:如果你不是在ubuntu本机操作登陆,而是远程通过ssh登录时,ssh username@ip地址 要加 -X, 否则X11会显示FALSE

 

2.2 在R中安装shiny模块

在R命令行中运行 install.packages("shiny")

> install.packages("shiny")

运行成功后(ctl + C)退出R界面

2.3 安装shiny-server

bonnie@bonnie0:~$ sudo apt-get install gdebi-core
bonnie@bonnie0:~$ wget https://download2.rstudio.org/rstudio-server-1.0.44-amd64.deb
bonnie@bonnie0:~$ sudo gdebi rstudio-server-1.0.44-amd64.deb

2.4 启动与关闭 shiny-server

start shiny-server        # 启动
stop shiny-server      # 停止
restart shiny-server     # 重启
status shiny-server     #查看状态 
reload shiny-server     #不中断服务的前提下 更新加载配置项

 

2.5 登陆web界面查看运行情况

http://10.211.55.16:3838/   默认端口时3838,可以在配置文件(/etc/shiny-server/shiny-server.conf)中修改

 

 

posted @ 2016-12-10 23:52  郭应文  阅读(4404)  评论(0编辑  收藏  举报