Shiny Server安装

作者: JeremyL | 来源:发表于2020-09-15 10:48 被阅读0次

    #为什么要使用Shiny Server

    Shiny Server使用户可以在网络上托管和管理Shiny应用程序。Shiny是一个R包,运用反应式编程模型
    简化Web程序开发。Shiny Server可以通过不同的URLs 和端口管理不同的R程序。

    使用Shiny Server的好处有:

    • 同时托管多个应用程序,每个应用程序都有自己的URL。
    • 支持不支持WebSocket的Web浏览器,包括Internet Explorer 8和9。
    • 用户能够开发和管理自己的Shiny应用程序。
    • R进程崩溃或终止并不影响下一个用户请求该应用程序。

    Shiny Server专业版(Shiny Server Professional)有跟多的功能:

    • 确保您的应用程序受到保护,并且只能由经过身份验证的用户访问。
    • 一个Shiny应用程序可以支持多个用户同时访问。
    • 通过使用Web仪表板监视Shiny应用程序的性能和使用情况,可以深入了解它们。
    • 使用SSL对发送到应用程序和从应用程序获取的数据进行安全加密。
    • 了解和管理当前和历史应用程序资源利用率,以更好地配置和优化应用程序。
    • 通过根据并发会话数配置多进程Shiny应用程序,微调专用于应用程序每个用户的资源。
    • 使用运行状况检查端点监视Shiny Server的运行状况。

    #系统要求

    Shiny Server当前仅能在Linux 操作系统运行,并且只支持64位系统:

    • RedHat Enterprise Linux(和CentOS)6及更高版本
    • Ubuntu 14.04及更高版本
    • SUSE Linux Enterprise 12及更高版本
      我们目前仅支持x86-64体系结构。

    #安装

    Shiny Server安装之前需要先安装 R 和Shiny 包。

    $ sudo apt-get install r-base
    

    注意:如果您没有按如上所述添加CRAN Debian或Ubuntu存储库,则此命令将安装与您当前系统版本相对应的R版本。可能是老版本的R。

    • Shiny包安装
    $ sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
    或者
    $ R
    >install.packages('shiny')
    >library("shiny")
    
    • 安装gdebi(用于安装Shiny Server及其所有依赖项)和Shiny Server。
    $ sudo apt-get install gdebi-core
    $ wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.14.948-amd64.deb
    $ sudo gdebi shiny-server-1.5.14.948-amd64.deb
    

    Shiny Server将会被安装到/opt/shiny-server/,主要的执行程序在/opt/shiny-server/bin/shiny-server。

    • shiny-server命令
    #启动 
    $ sudo systemctl start shiny-server 
    #停止 
    $ sudo systemctl stop shiny-server 
    #重启
    $ sudo systemctl restart shiny-server
    #查看状态 
    $ sudo systemctl status shiny-server 
    #服务器重新初始化,但不会中断服务器当前进程或任何连接。
    $ sudo systemctl kill -s HUP --kill-who=main shiny-server
    $ sudo reload shiny-server
    #shiny-server状态
    $ sudo systemctl status shiny-server
    
    • 查看shiny-server
      打开浏览器输入: http://IP:端口/
      HTTP

    IP:使用ip addr查看
    端口默认:3838。

    shiny
    • shiny-server配置
      shiny-server 配置文件
    /etc/shiny-server/shiny-server.conf
    /opt/shiny-server/config/default.config
    
    $ vi  /etc/shiny-server/shiny-server.conf
    # Define the user we should use when spawning R Shiny processes
    run_as shiny;
    
    # Define a top-level server which will listen on a port
    server {
      # Instruct this server to listen on port 3838
      listen 3838;
    
      # Define the location available at the base URL
      location / {
        #### PRO ONLY ####
        # Only up tp 20 connections per Shiny process and at most 3 Shiny processes
        # per application. Proactively spawn a new process when our processes reach 
        # 90% capacity.
        utilization_scheduler 20 .9 3;
        #### END PRO ONLY ####
    
        # Run this location in 'site_dir' mode, which hosts the entire directory
        # tree at '/srv/shiny-server'
        site_dir /srv/shiny-server;
        
        # Define where we should put the log files for this location
        log_dir /var/log/shiny-server;
        
        # Should we list the contents of a (non-Shiny-App) directory when the user 
        # visits the corresponding URL?
        directory_index on;
      }
    }
    
    # Setup a flat-file authentication system. {.pro}
    auth_passwd_file /etc/shiny-server/passwd;
    
    # Define a default admin interface to be run on port 4151. {.pro}
    admin 4151 {
      # Only permit the user named `admin` to access the admin interface.
      required_user admin;
    }
    

    #参考

    Shiny Server Professional v1.5.14 Administrator's Guide

    系列文章:
    Shiny 初步了解
    一个 Shiny app的基本组成部分

    相关文章

      网友评论

        本文标题:Shiny Server安装

        本文链接:https://www.haomeiwen.com/subject/ydgxyktx.html