shiny server安装 配置 管理

来源:互联网 发布:常用国家域名 编辑:程序博客网 时间:2024/06/05 18:48
shiny server是一种可用把R 语言以web形式展示的服务
环境:OEL5.9 64bit

1、安装R 环境
    http://blog.chinaunix.net/uid-25135004-id-4173752.html
2、安装shiny (两种方法)
    1)方法一网络安装
        1>R 进入命令行
        2>install.packages('shiny')
    2)方法二下载相关包,安装
        1>下载一下包
            http://mirror.bjtu.edu.cn/cran/src/contrib/Rcpp_0.11.1.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/bitops_1.0-6.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/httpuv_1.2.3.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/caTools_1.16.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/RJSONIO_1.0-3.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/xtable_1.7-3.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/digest_0.6.4.tar.gz
            http://mirror.bjtu.edu.cn/cran/src/contrib/shiny_0.9.1.tar.gz
    2>安装
             R CMD INSTALL Rcpp_0.11.1.tar.gz
             R CMD INSTALL bitops_1.0-6.tar.gz 
             R CMD INSTALL httpuv_1.2.3.tar.gz 
             R CMD INSTALL caTools_1.16.tar.gz 
             R CMD INSTALL RJSONIO_1.0-3.tar.gz
             R CMD INSTALL xtable_1.7-3.tar.gz 
             R CMD INSTALL digest_0.6.4.tar.gz 
             R CMD INSTALL shiny_0.9.1.tar.gz 

3、验证shinay包是否成功安装(进入R 命令行)
    > library("shiny") 无报错

4、下载shiny-server

    wget http://download3.rstudio.org/centos-5.9/x86_64/shiny-server-1.2.1.362-x86_64.rpm

其它版本:

    http://www.rstudio.com/products/shiny/download-server/

  
5、安装shiny-server
    yum install --nogpgcheck shiny-server-1.2.1.362-x86_64.rpm

6、shiny-server 配置

 相关网址:http://rstudio.github.io/shiny-server/latest/

1) 配置文件路径(默认)

 /etc/shiny-server/shiny-server.conf

2)配置内容

  1. # Instruct Shiny Server to run applications as the user "shiny"
  2. run_as shiny;
  3. # Define a server that listens on port 3838
  4. server {
  5. listen 8080;
  6. # Define a location at the base URL
  7. location / {
  8. # Host the directory of Shiny Apps stored in this directory
  9. site_dir /export/shiny-server/data;
  10. # Log all Shiny output to files in this directory
  11. log_dir /var/log/shiny-server;
  12. # When a user visits the base URL rather than a particular application,
  13. # an index of the applications available in this directory will be shown.
  14. directory_index on;
  15. }
  16. }

3)应用程序位置

Shiny Server默认会在/srv/shiny-server/目录查找你的Apps程序

可以把你开发的apps拷贝这个目录下:

sudo cp -R ~/MY-APP /srv/shiny-server/
如把Shiny自带的示例复制到这个目录下
--使用下面的命令查看library包的位置
# R -e ".libPaths()" --quiet
> .libPaths()
[1] "/usr/lib64/R/library" "/usr/share/R/library"


# cp -r /usr/lib64/R/library/shiny/examples/* /srv/shiny-server/

这样,访问你应用程序的地址就为:
http://<hostname>:3838/APP_NAME/


7、shiny-server 管理
    相关网址:http://rstudio.github.io/shiny-server/latest/
    1)启动,关闭,重启,查看状态命令
        start shiny-server
        stop shiny-server
        restart shiny-server
        status shiny-server

     
2)不中断服务加载配置

           reload shiny-server

注意:安装上shiny server后默认是开启的。

8、下面就可以访问你的应用于了

# ls /srv/shiny-server/

01_hello  03_reactivity  05_sliders  07_widgets  09_upload    11_timer  index.html
02_text   04_mpg         06_tabsets  08_html     10_download  hrl12580  sample-apps


WEB浏览:




参考:http://blog.chinaunix.net/uid-25135004-id-4194783.html


0 0
原创粉丝点击