闪亮的服务器 - 如何在localhost中安装软件包?

时间:2016-01-31 09:58:46

标签: r shiny-server shiny

我已按照here步骤在本地计算机上安装了Shiny Server。

我还设法让http://127.0.0.1:3838/sample-apps/hello/

运行默认的示例应用

但是当我想运行我一直在使用RStduio的应用程序时,我收到此错误,

  

发生错误

     

应用程序无法启动。

     

应用程序在初始化期间退出。

     

库中的错误(plyr):没有名为'plyr'的包调用:   runApp ... sourceUTF8 - > eval - > eval - > ..stacktraceon .. - >图书馆   执行暂停

我已经通过RStudio安装了所有软件包,它们就在这个目录中,

/home/tealou/R/x86_64-pc-linux-gnu-library/3.2/

我可以看到已经安装了plyr。

.../3.2/
      plyr/

但是为什么Shiny Server没有拿起上面目录中的软件包?

我应该在哪里安装服务器的软件包呢?怎么样?

有什么想法吗?

修改

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
    PATH=/home/tealou/R/x86_64-pc-linux-gnu-library/3.2/
  }
}

2 个答案:

答案 0 :(得分:1)

shiny-server.conf文件是否知道在系统中查找R安装的位置?

请阅读:

  

Shiny Server期望R可用作名为R和的可执行文件   是在运行shiny-server as的用户的PATH中。请注意   在一些CentOS系统中,PATH将被启动脚本覆盖   to / sbin:/ usr / sbin:/ bin:/ usr / bin。在这样的系统上,如果R不是   可在其中一个位置使用(无论用户的路径如何),   你需要调整启动脚本。

     

要允许Shiny Server在其他位置搜索R,您需要   改变/etc/init.d/shiny-server或中的文件   /etc/init/shiny-server.conf取决于你是哪个启动系统   使用(如停止和开始中所述。您可以调整   PATH变量包含将找到R的目录,或   您可以设置一个名为R的环境变量来告诉Shiny Server   确切地说它应该在哪里查找可执行文件。

     

如果选择调整PATH,可以添加其中的目录   找到名为R的可执行文件到定义PATH的行   环境变量(PATH = / sbin:/ usr / sbin:/ bin:/ usr / bin)。

以及更多内容可在此处获取:https://rstudio.github.io/shiny-server/latest/#configuration-settings

一个明显的问题以防万一:您的代码中有library(plyr),对吧?

答案 1 :(得分:0)

当闪亮服务器在shiny用户上运行时,提供任何软件包的最佳方法是通过以下方式为所有用户安装该软件包:

sudo su - -c "R -e \"install.packages(c('plyr'), repos='http://cran.rstudio.com/')\""

通过此解决方案,您无需对conf文件进行任何更改。

相关问题