搜索
查看: 2188|回复: 0

R的shiny 服务器管理-入门

[复制链接]

634

主题

1182

帖子

4030

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4030
发表于 2017-3-24 11:22:44 | 显示全部楼层 |阅读模式
好,我当初写了这个教程,现在自己就用上了,感谢我自己~~~
原帖:http://www.bio-info-trainee.com/1677.html
不过原帖说的是CentOS 6.5.,但是我现在要用ubuntu16.04
如果你已经安装好了shiny 服务器,(安装教程)要开始使用了,掌握一些基础知识是必须的。这里我简单学习了一些入门资料,分享给大家,慢慢的我会写一个进阶资料。安装成功之后,系统会增加4个目录,是一定要掌握的:
1、这个目录只存放关键配置文件:/etc/shiny-server/shiny-server.conf   初始状态只有一个文件,记录着非常多的默认信息,默认的网站目录是根目录下的srv的shiny-server目录,端口是3838

2、网站运行log日子存放:/var/log/shiny-server  初始状态下该目录为空
3、程序存放目录是:/srv/shiny-server 初始状态,有一个测试程序:
4、最后是/opt/shiny-server/ 目录,这里面也有一个配置文件:/opt/shiny-server/config/default.config

还有一个比较重要的文件,取决于linux系统的种类
/etc/systemd/system/shiny-server.service 我的是 (RedHat 7, Ubuntu 15.04+, SLES 12+)
如果是其它一些旧的系统会是/etc/init/shiny-server.conf  (Ubuntu 12.04 through 14.10 and RedHat 6)
或者更旧的系统 /etc/init.d/shiny-server   (RedHat 5, SLES 11)


关于shiny 服务器常见的需要控制的命令,基于我的linux系统版本(RedHat 7, Ubuntu 15.04+, SLES 12+)
sudo systemctl start shiny-server
sudo systemctl stop shiny-server
sudo systemctl restart shiny-server
sudo systemctl kill -s HUP --kill-who=main shiny-server
sudo systemctl status shiny-server  ## 查看状态
sudo systemctl enable shiny-server  ## 开机启动
sudo systemctl disable shiny-server ## 关闭开机启动
## 如果是其它linux版本,请参照shiny官网的服务器维护指南:http://rstudio.github.io/shiny-server/latest/

关于shiny 服务器配置,虽然默认根目录下的/srv的shiny-server目录,端口是3838
[AppleScript] 纯文本查看 复制代码
server { 
 listen 3838;location / {    
site_dir /srv/shiny-server;
log_dir /var/log/shiny-server;
directory_index on;  
}}
可以设置多个端口监听server {  listen 4949;
location / {    
site_dir /srv/shiny-server;
log_dir /var/log/shiny-server;
directory_index on; } }

因为我们是以shiny这个用户来运行这些shiny的web app的,所以要给予一定的目录一些适当的权限给shiny用户。

首先是需要写的目录
  • /var/lib/shiny-server/ (or whatever custom SHINY_DATA_DIR setting you're using)
  • /var/log/shiny-server/ (and/or whatever other directories you use for logging)

然后是需要读取的目录
  • /srv/shiny-server/ (and/or whatever other directories you're using to host Shiny applications)
  • /opt/shiny-server/
  • /etc/shiny-server/ (Note that you should enable only read access on this directory, as you likely don't want to allow your Shiny applications (which also run as shiny) to be able to write to your configuration or password file.)

还有,如果/tmp/shiny-server/目录存在的话,也需要设置好相应的权限。


然后就可以把shiny官网的例子克隆到自己的服务器里面,开始在shiny的世界里面遨游啦!
git clone https://github.com/rstudio/shiny-examples.git

还有 https://github.com/ua-snap/shiny-apps

网页运行里面会经常需要Rmarkdown
sudo su - -c "R -e \"install.packages('rmarkdown',repos='http://mirror.bjtu.edu.cn/cran/')\""


收费版本还有很多其它功能:
The app_session_timeout setting can be used to automatically disconnect idle Shiny connections.
Shiny Server is capable of automatically inserting the necessary JavaScript code to enable Google Analytics tracking globally or for a particular server or location.
Memory limits will be added in a coming version of Shiny Server Professional.
Shiny Server can use a wide variety of techniques to keep the data in the web browser synchronized. The preferred technique, and the one most widely used, is the use of WebSockets.
Shiny Server Professional offers the ability to authenticate individual users. By specifying authentication requirements on particular servers or locations, the administrator can control the set of applications particular users are allowed to access.( session$user  和 session$groups)
Regardless of which authentication mechanism is used, the duration of authentication can be configured using the auth_duration setting.
Shiny Server Pro supports the ability to rely on Google for the management of your users using the auth_google setting.
In Shiny Server Professional, SSL encryption is available for any configured server and in the admininterface. SSL is a means of encrypting traffic between web clients and servers and should be used for any application that will accept or transmit sensitive information such as passwords.




你这个问题很复杂,需要打赏,请点击 http://www.bio-info-trainee.com/donate 进行打赏,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生信技能树 ( 粤ICP备15016384号  

GMT+8, 2019-10-21 09:21 , Processed in 0.041812 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.