ユーザ用ツール

サイト用ツール


linux:shiny_server:shinyserver

文書の過去の版を表示しています。


Shiny Server

 RでWebアプリケーションを開発するためのパッケージShinyをWebアプリケーションとして動作させるためのサーバ。オンプレミスの有償版は金額が高く、ホスティングサービスは無償アカウントもあるがデータを外部のサーバに置くのは問題が多いため、オープンソース版を使う。いくつかのOSではパッケージが用意されているが、Gentoo向けには無いのでソースからビルドする。

事前準備

Pythonと親和性が高いGentooでは特に事前にインストールするものはない。R自体はインストールする必要がある。

ビルドとインストール

 基本的にマニュアル通り。以前は1ステップ必要な手順が抜けていて、コミュニティの書き込みを参照する必要があったが、修正されているようだ。

> git clone https://github.com/rstudio/shiny-server.git
> cd shiny-server
> mkdir tmp
> cd tmp
> ../external/node/install-node.sh

# 環境変数をセット
> DIR=`pwd`
> PATH=$DIR/../bin:$PATH
>  cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../

> make
> mkdir ../build
> (cd .. && ./bin/npm install)
> (cd .. && ./bin/node ./ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild)
> make install

# 設定ファイルを配置するディレクトリの作成
> mkdir /etc/shiny-server 
> cp ../config/default.config /etc/shiny-server/shiny-server.conf

shinyユーザを作成し、各種ディレクトリ等を作成する。

今回は、/home/shinyをホームディレクトリとしたshinyユーザを作成し、各種ディレクトリもここに集約する。shinyユーザにはシェルを与えずログインできないようにしておく。

  • ${shiny_home}/log
  • ${shiny_home}/server
  • ${shiny_home}/lib
  • ${shiny_home}/bookmarks

設定

/etc/shiny-server/shiny-server.confを上記ディレクトリ構成にあわせて設定する。

マニュアルにはないが、bookmarksディレクトリを書き込み可能な形で設定しておかないと、サーバが起動しない。

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

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

  # Define a location at the base URL                                                                              
  location / {

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

    # Log all Shiny output to files in this directory                                                              
    log_dir /home/shiny/log;

    # Bookmark dir                                                                                                 
    bookmark_state_dir /home/shiny/bookmarks;

    # 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;
  }
}
linux/shiny_server/shinyserver.1583207944.txt.bz2 · 最終更新: 2020/03/03 12:59 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki