<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; shiny服务器</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/shiny%e6%9c%8d%e5%8a%a1%e5%99%a8/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>R的shiny 服务器管理-入门</title>
		<link>http://www.bio-info-trainee.com/1683.html</link>
		<comments>http://www.bio-info-trainee.com/1683.html#comments</comments>
		<pubDate>Sat, 04 Jun 2016 01:14:09 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[生信基础]]></category>
		<category><![CDATA[shiny]]></category>
		<category><![CDATA[shiny服务器]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1683</guid>
		<description><![CDATA[如果你已经安装好了shiny 服务器，(安装教程)要开始使用了，掌握一些基础知识 &#8230; <a href="http://www.bio-info-trainee.com/1683.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>如果你已经安装好了shiny 服务器，(<a href="http://www.bio-info-trainee.com/1677.html">安装教程</a>)要开始使用了，掌握一些基础知识是必须的。这里我简单学习了一些入门资料，分享给大家，慢慢的我会写一个进阶资料。安装成功之后，系统会增加4个目录，是一定要掌握的：</p>
<blockquote>
<div><span style="color: #ff0000;">1、这个目录只存放关键配置文件：/etc/shiny-server/shiny-server.conf   初始状态只有一个文件，记录着非常多的默认信息，默认的网站目录是根目录下的srv的shiny-server目录，端口是3838<br />
</span></div>
<div>2、网站运行log日子存放：/var/log/shiny-server  初始状态下该目录为空</div>
<div>3、程序存放目录是：/srv/shiny-server 初始状态，有一个测试程序：</div>
</blockquote>
<div>
<blockquote>
<div>4、最后是/opt/shiny-server/ 目录，这里面也有一个配置文件：/opt/shiny-server/config/default.config</div>
</blockquote>
</div>
<p><span id="more-1683"></span></p>
<div>还有一个比较重要的文件，取决于linux系统的种类</div>
<div><strong>/etc/systemd/system/shiny-server.service 我的是 (RedHat 7, Ubuntu 15.04+, SLES 12+)</strong></div>
<div>如果是其它一些旧的系统会是/etc/init/shiny-server.conf  (Ubuntu 12.04 through 14.10 and RedHat 6)</div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">或者更旧的系统 </span>/etc/init.d/shiny-server   (RedHat 5, SLES 11)</div>
<div></div>
<div></div>
<div>关于shiny 服务器常见的需要控制的命令,基于我的linux系统版本<strong>(RedHat 7, Ubuntu 15.04+, SLES 12+)</strong></div>
<div>
<div>sudo systemctl start shiny-server</div>
<div>sudo systemctl stop shiny-server</div>
<div>sudo systemctl restart shiny-server</div>
<div>sudo systemctl kill -s HUP --kill-who=main shiny-server</div>
<div>sudo systemctl status shiny-server  ## 查看状态</div>
<div>sudo systemctl enable shiny-server  ## 开机启动</div>
<div>sudo systemctl disable shiny-server ## 关闭开机启动</div>
<div>## 如果是其它linux版本，请参照shiny官网的服务器维护指南：<a href="http://rstudio.github.io/shiny-server/latest/">http://rstudio.github.io/shiny-server/latest/</a></div>
<div></div>
<div>
<div>关于shiny 服务器配置，虽然默认根目录下的/srv的shiny-server目录，端口是3838</div>
<div>
<pre><code>server {
  listen 3838;location / {</code></pre>
<pre>    site_dir /srv/shiny-server;</pre>
<pre><code>log_dir /var/log/shiny-server;directory_index on;
  }
}</code></pre>
<pre><code>可以设置多个端口监听</code></pre>
<pre><code>server {
  listen 4949;location / {</code></pre>
<pre>    site_dir /srv/shiny-server;</pre>
<pre><code>log_dir /var/log/shiny-server;directory_index on; } }</code></pre>
<p>因为我们是以shiny这个用户来运行这些shiny的web app的，所以要给予一定的目录一些适当的权限给shiny用户。</p></div>
<div>首先是需要写的目录</div>
<div>
<ul>
<li><code>/var/lib/shiny-server/</code> (or whatever custom <code>SHINY_DATA_DIR</code> setting you're using)</li>
<li><code>/var/log/shiny-server/</code> (and/or whatever other directories you use for logging)</li>
</ul>
</div>
<div>然后是需要读取的目录</div>
<div>
<ul>
<li><code>/srv/shiny-server/</code> (and/or whatever other directories you're using to host Shiny applications)</li>
<li><code>/opt/shiny-server/</code></li>
<li><code>/etc/shiny-server/</code> (Note that you should enable <strong>only</strong> read access on this directory, as you likely don't want to allow your Shiny applications (which also run as <code>shiny</code>) to be able to write to your configuration or password file.)</li>
</ul>
</div>
<div>还有，如果<code>/tmp/shiny-server/目录存在的话，也需要设置好相应的权限。</code></div>
<div><code> </code></div>
<div></div>
<div>然后就可以把shiny官网的例子克隆到自己的服务器里面，开始在shiny的世界里面遨游啦！</div>
<div>
<div>git clone <a href="https://github.com/rstudio/shiny-examples.git">https://github.com/rstudio/shiny-examples.git</a></div>
</div>
<div>还有 <a href="https://github.com/ua-snap/shiny-apps">https://github.com/ua-snap/shiny-apps</a></div>
<div></div>
<div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">网页运行里面会经常需要Rmarkdown</span></div>
<div>
<div>sudo su - -c "R -e \"install.packages('rmarkdown',repos='<a href="http://mirror.bjtu.edu.cn/cran/">http://mirror.bjtu.edu.cn/cran/</a>')\""</div>
</div>
</div>
<div>收费版本还有很多其它功能:</div>
<div>The <code>app_session_timeout</code> setting can be used to automatically disconnect idle Shiny connections.</div>
<div>Shiny Server is capable of automatically inserting the necessary JavaScript code to enable Google Analytics tracking globally or for a particular <code>server</code> or <code>location</code>.</div>
<div>Memory limits will be added in a coming version of Shiny Server Professional.</div>
<div>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.</div>
<div>Shiny Server Professional offers the ability to authenticate individual users. By specifying authentication requirements on particular <code>server</code>s or <code>location</code>s, the administrator can control the set of applications particular users are allowed to access.(<code> session$user  和 </code><code>session$groups</code>)</div>
<div>Regardless of which authentication mechanism is used, the duration of authentication can be configured using the <code>auth_duration</code> setting.</div>
<div>Shiny Server Pro supports the ability to rely on Google for the management of your users using the <code>auth_google</code> setting.</div>
<div>In Shiny Server Professional, SSL encryption is available for any configured <code>server</code> and in the <code>admin</code> interface. 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.</div>
</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1683.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装自己的shiny服务器-实战指南</title>
		<link>http://www.bio-info-trainee.com/1677.html</link>
		<comments>http://www.bio-info-trainee.com/1677.html#comments</comments>
		<pubDate>Sat, 04 Jun 2016 01:07:29 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[生信基础]]></category>
		<category><![CDATA[shiny服务器]]></category>
		<category><![CDATA[网页]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1677</guid>
		<description><![CDATA[个人比较欣赏R shiny制作的网页，入门简单，上手极快，多看点例子，制作复杂逻 &#8230; <a href="http://www.bio-info-trainee.com/1677.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>个人比较欣赏R shiny制作的网页，入门简单，上手极快，多看点例子，制作复杂逻辑的网页也不是问题。这篇实战指南有四个步骤：</p>
<blockquote><p>至少需要root权限的linux系统  （我测试了阿里云）<br />
安装R   （一般安装最新版，）<br />
在R中安装shiny模块   （一般还可以多安装一些模块）<br />
下载并且安装shiny server安装包    （根据系统选择）</p></blockquote>
<p><span id="more-1677"></span></p>
<p>前面三个步骤没有什么好说的了，如果你需要继续看这篇指南，我就默认你已经会了。</p>
<div>那么重点，就是安装shiny server本身咯：</div>
<div>这里<a href="http://www.rstudio.com/products/shiny/download-server/">http://www.rstudio.com/products/shiny/download-server/</a> 提供了下载链接，需要提供邮箱才会出现下载页面，选择对应Linux发行版的Shiny Server进行下载。<strong>我这里是CentOS 6.5.</strong></div>
<div></div>
<blockquote>
<div><strong>64bit</strong><br />
Size:  44.6 MB<br />
MD5: 45160b08eed65c89e0a9d03c58eba595<br />
Version:  1.4.2.786<br />
Released:  2016-02-19</div>
<div>#直接下载安装包，所以非常简单，我的命令是：</div>
<div><code>sudo yum install R</code></div>
<div><code><code>$ wget https://download3.rstudio.org/centos5.9/x86_64/<span style="color: #ff0000;">shiny-server-1.4.2.786-rh5-x86_64.rpm</span><br />
$ sudo yum install --nogpgcheck <strong>shiny-server-1.4.2.786-rh5-x86_64.rpm</strong></code><br />
</code></div>
</blockquote>
<div>这里我也是学习的别人的方法，参考：</div>
<div><a href="http://ju.outofmemory.cn/entry/162254">http://ju.outofmemory.cn/entry/162254</a></div>
<div>
<div><a href="http://www.lai18.com/content/1733097.html">http://www.lai18.com/content/1733097.html</a></div>
<div><strong>如果系统很烂，缺少一堆的库文件，</strong>简单的<code>sudo yum install</code>还会各种报错，如果需要下载源码来安装，那会很麻烦，这里就不讨论了。</div>
<div></div>
<div>如果安装成功，就有下面的界面：</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/11.png"><img class="alignnone size-full wp-image-1678" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/11.png" alt="1" width="440" height="472" /></a></div>
<div>成功之后就可以浏览shiny的网页了，程序自带测试例子，如果是在本地linux系统，而且自带浏览器的界面版linux，那么直接在浏览器中输入 localhost:3838 (或者对应IP地址， 如 <a href="http://192.168.1.100:3838/">http://192.168.1.100:3838/</a> 这个IP是假的 )就会出现。</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/4.png"><img class="alignnone size-full wp-image-1681" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/4.png" alt="4" width="694" height="380" /></a></div>
<div></div>
<div>但是阿里云服务器访问一般通过外网链接，因为要通过你的真正IP来访问3838端口，<strong>所以需要设置防火墙规则，不然依然是不能访问，防火墙自己学习如何设置把。</strong></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/3.png"><img class="alignnone size-full wp-image-1680" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/3.png" alt="3" width="593" height="264" /></a></div>
<div>安装成功了之后，还有一个更重要的事情就是维护，我下面简单介绍一些，然后会写一篇维护心得体会：</div>
<div>
<div>shiny官网上提供了详细的配置指导</div>
<div><a href="http://rstudio.github.io/shiny-server/latest/">http://rstudio.github.io/shiny-server/latest/</a></div>
<div>
<div>shiny-server 默认的安装目录是：/opt/shiny-server</div>
<div>目录内容：</div>
<div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/21.png"><img class="alignnone size-full wp-image-1679" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/21.png" alt="2" width="514" height="100" /></a></div>
<div></div>
<div>其中的默认配置文件是：/opt/shiny-server/config/default.config</div>
<div>内容是：</div>
<div></div>
</div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"># Instruct Shiny Server to run applications as the user “shiny”</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">run_as shiny;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"># Define a server that listens on port 3838</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">server {</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  listen 3838;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  # Define a location at the base URL</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  location / {</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # Host the directory of Shiny Apps stored in this directory</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    site_dir /srv/shiny-server;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # Log all Shiny output to files in this directory</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    log_dir /var/log/shiny-server;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;"> </span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # When a user visits the base URL rather than a particular application,</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    # an index of the applications available in this directory will be shown.</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">    directory_index on;</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">  }</span></div>
<div><span style="font-family: Monaco,Consolas,Courier,Lucida Console,monospace;">}</span></div>
<div>
<div></div>
<div><span style="color: #ff0000;">这个文件和/etc/shiny-server/shiny-server.conf是一样的。</span></div>
<div><span style="color: #ff0000;">后面会具体讲解shiny server的配置细节。正如配置文件中所写，默认的网站目录是根目录下的srv的shiny-server目录，端口是3838，log目录是 /var/log/shiny-server。</span></div>
<div>
<div>默认程序存放在： <strong>/srv/shiny-server</strong></div>
<div>lrwxrwxrwx. 1 root root 38 Nov 25 00:02 index.html -&gt; /opt/shiny-server/samples/welcome.html</div>
<div>lrwxrwxrwx. 1 root root 37 Nov 25 00:02 sample-apps -&gt; /opt/shiny-server/samples/sample-apps</div>
<div>其实就是opt下对应的链接。</div>
</div>
</div>
</div>
</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1677.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
