How to install and run Shiny Server on the Raspberry Pi 3 and Raspian Jassie Lite

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@m4rk.h4nn4·
0.000 HBD
How to install and run Shiny Server on the Raspberry Pi 3 and Raspian Jassie Lite
<html>
<p><img src="https://i.imgur.com/gYUS4dg.png"/></p>
<h2>Welcome!</h2>
<p>According to <a href="https://steemit.com/introduceyourself/@m4rk.h4nn4/hello-steemit">my first post</a> and as promised, here is my first tutorial, from which you will learn how to install and run smoothly R Shiny Server on the Raspberry Pi 3 - $50 mini computer. If you use R-programming, you probably know Shiny package.</p>
<p><a href="http://shiny.rstudio.com/"><em>Shiny</em></a><em> is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in </em><a href="http://rmarkdown.rstudio.com/"><em>R Markdown</em></a><em> documents or build </em><a href="http://rstudio.github.io/shinydashboard/"><em>dashboards</em></a><em>. You can also extend your Shiny apps with </em><a href="http://rstudio.github.io/shinythemes/"><em>CSS themes</em></a><em>, </em><a href="http://www.htmlwidgets.org/"><em>htmlwidgets</em></a><em>, and JavaScript </em><a href="https://github.com/daattali/shinyjs/blob/master/README.md"><em>actions</em></a><em>.</em></p>
<h6>Dashboards Examples:</h6>
<p><img src="http://rstudio.github.io/shinydashboard/images/dashboard.png" width="496" height="300"/></p>
<p><img src="http://rstudio.github.io/shinydashboard/images/buses.png" width="496" height="473"/></p>
<h6>Charts Examples:</h6>
<p><img src="https://i.imgur.com/C0ZkT1S.png"/></p>
<h2>Tutorial</h2>
<p>How to install and run Shiny Server on the Raspberry Pi 3 with fresh Raspbian Jessie Lite?</p>
<h5>First, update and upgrade:</h5>
<pre><code>sudo apt-get update &amp;&amp; sudo apt-get upgrade -y</code></pre>
<p><br></p>
<h5>Install base R:</h5>
<pre><code>sudo apt-get install r-base r-base-core r-base-dev</code></pre>
<p><br></p>
<h5>Check if R is installed properly:</h5>
<pre><code>R</code></pre>
<pre><code>q()</code></pre>
<p>Just run R and quit.</p>
<h5>Download and install dependent packages directly from the cran repo.</h5>
<p>Look for: Rcpp, httpuv, mime, jsonlite, digest, htmltools, xtable, R6, Cairo, sourcetools, shiny. You can check and download actual versions of this packages here: https://cran.r-project.org/src/contrib/</p>
<h6>Below links to the the latest versions of the above packages (at the moment 2018-01-27):</h6>
<pre><code>wget https://cran.r-project.org/src/contrib/Rcpp_0.12.15.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/httpuv_1.3.5.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/mime_0.5.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/jsonlite_1.5.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/digest_0.6.14.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/htmltools_0.3.6.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/xtable_1.8-2.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/R6_2.2.2.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/Cairo_1.5-9.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/sourcetools_0.1.6.tar.gz</code></pre>
<pre><code>wget https://cran.r-project.org/src/contrib/shiny_1.0.5.tar.gz</code></pre>
<p><br></p>
<h6>Install downloaded packages with this method which is faster and less memory demanding than install.packages() in R:</h6>
<pre><code>sudo R CMD INSTALL Rcpp_0.12.15.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL httpuv_1.3.5.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL mime_0.5.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL jsonlite_1.5.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL digest_0.6.14.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL htmltools_0.3.6.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL xtable_1.8-2.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL R6_2.2.2.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL Cairo_1.5-9.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL sourcetools_0.1.6.tar.gz</code></pre>
<pre><code>sudo R CMD INSTALL shiny_1.0.5.tar.gz</code></pre>
<p>Run that, but remember to check the files versions.</p>
<h5>Check if Shiny package is installed:</h5>
<pre><code>R</code></pre>
<pre><code>library(shiny)</code></pre>
<pre><code>q()</code></pre>
<p>Just run R, load Shiny library and quit.</p>
<h5>Now download, extract and install <a href="https://cmake.org/">CMake</a>:</h5>
<pre><code>wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz</code></pre>
<pre><code>tar xzf cmake-3.10.2.tar.gz</code></pre>
<pre><code>cd cmake-3.10.2</code></pre>
<pre><code>./configure; make</code></pre>
<pre><code>sudo make install</code></pre>
<p>You can check the link to the latest version here https://cmake.org/files/</p>
<h5>Finally, we can install our own Shiny Server:</h5>
<pre><code>cd</code></pre>
<pre><code>git clone https://github.com/rstudio/shiny-server.git</code></pre>
<pre><code>cd shiny-server</code></pre>
<pre><code>DIR=`pwd`</code></pre>
<pre><code>PATH=$DIR/bin:$PATH</code></pre>
<pre><code>mkdir tmp</code></pre>
<pre><code>cd tmp</code></pre>
<pre><code>PYTHON=`which python`</code></pre>
<pre><code>sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DPYTHON="$PYTHON" ../</code></pre>
<pre><code>sudo make</code></pre>
<pre><code>mkdir ../build</code></pre>
<pre><code>(cd .. &amp;&amp; ./bin/npm --python="$PYTHON" rebuild)</code></pre>
<pre><code>(cd .. &amp;&amp; ./bin/node ./ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --python="$PYTHON" rebuild)</code></pre>
<pre><code>sudo make install</code></pre>
<p><br></p>
<h5>Last steps, post-Install with default configuration:</h5>
<pre><code>cd</code></pre>
<pre><code>sudo ln -s /usr/local/shiny-server/bin/shiny-server /usr/bin/shiny-server</code></pre>
<pre><code>sudo useradd -r -m shiny</code></pre>
<pre><code>sudo mkdir -p /var/log/shiny-server</code></pre>
<pre><code>sudo mkdir -p /srv/shiny-server</code></pre>
<pre><code>sudo mkdir -p /var/lib/shiny-server</code></pre>
<pre><code>sudo chown shiny /var/log/shiny-server</code></pre>
<pre><code>sudo mkdir -p /etc/shiny-server</code></pre>
<p><br></p>
<h5>Create Shiny Server configuration file:</h5>
<pre><code>cd</code></pre>
<pre><code>sudo cp shiny-server/config/default.config /etc/shiny-server/</code></pre>
<pre><code>sudo cp default.config shiny-server.conf</code></pre>
<p><br></p>
<h5>And now, we can add and run our first Shiny Application:</h5>
<pre><code>cd</code></pre>
<pre><code>sudo mkdir /srv/shiny-server/example</code></pre>
<pre><code>sudo cp shiny-server/samples/sample-apps/hello/ui.R /srv/shiny-server/example/</code></pre>
<pre><code>sudo cp shiny-server/samples/sample-apps/hello/server.R /srv/shiny-server/example/</code></pre>
<p>Copy sample app from cloned repo to the /srv/shiny-server/ directory.</p>
<h5>Change file permissions and run Shiny Server:</h5>
<pre><code>cd</code></pre>
<pre><code>sudo chmod 777 -R /srv</code></pre>
<pre><code>sudo shiny-server</code></pre>
<p><br></p>
<p>Now open your web browser and go to: {{your-raspberry-IP-adress}}:3838, e.g http://192.161.1.2:3838. Here is a list of your all aplications from /srv/shiny-server directory. Click on our example to run it. Enjoy! :)</p>
<p><img src="https://i.imgur.com/bNCf9K3.png"/></p>
</html>
👍 , , , , , , , , ,