shiny的安装

1. 安装 R

sudo apt install r-base

sudo yum install R

2. 安装 Rstudio-server

sudo apt-get install gdebi-core sudo apt-get install libapparmor1 wget https://download2.rstudio.org/rstudio-server-1.0.143-amd64.deb sudo gdebi rstudio-server-1.0.143-amd64.deb

因为Rstudio-server不能以root用户登录,所以我们需要创建一个用户

sudo addusr anlan ……

然后在网页上输入ip:8787进入Rstudio-server界面,输入用户和密码,即可登录

##3. 安装 Shiny

sudo su - -c “R -e "install.packages(‘shiny’, repos=‘http://cran.rstudio.com/')"”

不能直接进入R,然后install.packages(“shiny”),因为如果这样安装,是将shiny包安装下当前登录用户的个人library中,使得最终shiny-server无法运行

#Ubuntu下 (参考资料:https://www.rstudio.com/products/shiny/download-server/)

apt-get install gdebi-core

wget https://download3.rstudio.org/ubuntu-12.04/x86_64/shiny-server-1.5.3.838-amd64.deb

sudo gdebi shiny-server-1.5.3.838-amd64.deb

sudo yum install gdebi-core #我的服务器用yum下载 wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.5.3.838-rh5-x86_64.rpm sudo yum install –nogpgcheck shiny-server-1.5.3.838-rh5-x86_64.rpm

做完以上几步后,shiny-server算是初步安装好了,然后可以在网页上ip:3838进入shiny-server界面(ip是你服务器的ip地址)。一般我们能看到左边一列的文字和右边的两个框。当然还需要再安装个rmarkdown,不然还是会有error的

sudo su - -c “R -e "install.packages(‘rmarkdown’, repos=‘http://cran.rstudio.com/')"”

4. 配置shiny server

  • Shiny Server log is at /var/log/shiny-server.log
  • The default Shiny Server homepage you’re seeing is located at /srv/shiny-server/index.html - you can edit it or remove it.
  • Any Shiny app directory that you place under /srv/shiny-server/ will be served as a Shiny app. For example, there is a default app at /srv/shiny-server/sample-apps/hello/, which means you can run the app by going to http://123.456.1.2:3838/sample-apps/hello/
  • The config file for Shiny Server is at /etc/shiny-server/shiny-server.conf
  • To reload the server after editing the config, use sudo reload shiny-server
  • When hosting an Rmarkdown file, name the file index.rmd and add runtime: shiny to the document’s frontmatter

5. 赋予shiny权限

假设当你登录是以自己用户登录,你在shiny server创建的文件只有该用户(除了root)才有权限读写,但是shiny server是以shiny用户来运行shiny的app,所以要给予shiny用户在一些目录的权限。

例如:

sudo groupadd shiny-apps sudo usermod -aG shiny-apps qqin sudo usermod -aG shiny-apps shiny sudo chown -R qqin:shiny-apps /srv/shiny-server sudo chmod g+w /srv/shiny-server sudo chmod g+s /srv/shiny-server ####在该目录下创建的文件都属于该目录所属的组

6. 下载shiny官网的例子

git clone https://github.com/rstudio/shiny-examples.git

文件是要下载到/srv/shiny-server中

二、Mac 安装shiny

没有服务器的我,就只有在我的mac上安装shiny咯

1.准备安装

brew install python

2.安装

sudo R

install.packages(“shiny”, repo=“http://cran.rstudio.org”, type=“source”)

参考资料:

http://www.biotrainee.com/thread-1369-1-1.html

http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/

这里是一个广告位,,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn