How to Set-Up Shiny Server on Ubuntu


Shiny is an R package that allows Linux users to convert R code into an interactive webpage and documents online. You can take your shiny apps and share them in your organisation or the world. This article explains about how to set up shiny server on Ubuntu.

Installing Shiny Server on Ubuntu

Before installing Shiny server, we need to install the shiny R package. To install R packages, use the following command –

$ sudo apt-get install r-base

The sample output should be like this -

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
apport-hooks-elementary contractor javascript-common libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1
libindicate5 libjs-jquery libnoise-core0 libtagc0 mysql-server-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
bzip2-doc cdbs debhelper dh-strip-nondeterminism dh-translations gfortran gfortran-5 intltool libblas-common libblas-dev libblas3 libbz2-dev
libfile-stripnondeterminism-perl libgfortran-5-dev libgfortran3 liblapack-dev liblapack3 liblzma-dev liblzma5 libmail-sendmail-perl
libncurses5-dev libpcre3-dev libpcre32-3 libpcrecpp0v5 libpng12-dev libreadline-dev libreadline6-dev libsys-hostname-long-perl libtinfo-dev
po-debconf python-scour python-six r-base-core r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools
r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
r-cran-survival r-doc-html r-recommended
.......................................................................

We’re going to install Shiny server with the GDebi tool. To install GDebi, use the following command –

$ sudo apt-get install gdebi-core

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
apport-hooks-elementary contractor javascript-common libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1
libindicate5 libjs-jquery libnoise-core0 libtagc0 mysql-server-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
gdebi-core
0 upgraded, 1 newly installed, 0 to remove and 180 not upgraded.
Need to get 9,716 B of archives.
After this operation, 135 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 gdebi-core all 0.9.5.7ubuntu1 [9,716 B]
Fetched 9,716 B in 0s (31.5 kB/s)
Selecting previously unselected package gdebi-core.
(Reading database ... 189573 files and directories currently installed.)
Preparing to unpack .../gdebi-core_0.9.5.7ubuntu1_all.deb ...
Unpacking gdebi-core (0.9.5.7ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up gdebi-core (0.9.5.7ubuntu1) ...
...........................................................................................

To download Shiny server, use the following command –

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

The sample output should be like this –

--2016-05-16 11:38:20-- https://download3.rstudio.org/ubuntu-12.04/x86_64/shiny-server-1.4.2.786-amd64.deb
Resolving download3.rstudio.org (download3.rstudio.org)... 54.230.190.35, 54.230.190.248, 54.230.190.84, ...
Connecting to download3.rstudio.org (download3.rstudio.org)|54.230.190.35|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53653388 (51M) [application/octet-stream]
Saving to: ‘shiny-server-1.4.2.786-amd64.deb’

shiny-server-1.4.2.786-amd64.deb 100%[===================================================================>] 51.17M 408KB/s in 2m 26s

2016-05-16 11:40:48 (358 KB/s) - ‘shiny-server-1.4.2.786-amd64.deb’ saved [53653388/53653388]

Now use GDebi to install the file that was downloaded using the following command –

$ sudo gdebi shiny-server-1.4.2.786-amd64.deb

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done

Shiny Server
Shiny Server is a server program from RStudio, Inc. that makes Shiny applications available over the web. Shiny is a web application framework for the R statistical computation language.
Do you want to install the software package? [y/N]:y
Selecting previously unselected package shiny-server.
(Reading database ... 189587 files and directories currently installed.)
Preparing to unpack shiny-server-1.4.2.786-amd64.deb ...
Unpacking shiny-server (1.4.2.786) ...
Setting up shiny-server (1.4.2.786) ...
Creating user shiny
Adding LANG to /etc/systemd/system/shiny-server.service, setting to en_IN
Created symlink from /etc/systemd/system/multi-user.target.wants/shiny-server.service to /etc/systemd/system/shiny-server.service.
shiny-server.service - ShinyServer
Loaded: loaded (/etc/systemd/system/shiny-server.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2016-05-16 11:42:45 IST; 36ms ago
Process: 1583 ExecStartPost=/bin/sleep 3 (code=exited, status=0/SUCCESS)
Main PID: 1584 (shiny-server)
Tasks: 8 (limit: 512)
CGroup: /system.slice/shiny-server.service
      ├─1582 /bin/bash -c /opt/shiny-server/bin/shiny-server --pidfile=/var/run/shiny-server.pid >>                   /var/log/shiny-server.log 2>&1
      └─1584 /opt/shiny-server/ext/node/bin/shiny-server /opt/shiny-server/lib/main.js --pidfile=/var/run/shiny-server.pid

May 16 11:42:42 linux systemd[1]: Starting ShinyServer...
May 16 11:42:45 linux systemd[1]: shiny-server.service: Supervising process 1584 which is not our child. We'll most likely not notice...t exits.
May 16 11:42:45 linux systemd[1]: Started ShinyServer.
Hint: Some lines were ellipsized, use -l to show in full.

Shiny Server should now be installed and running on port 3838. You should be able to see a default welcome screen at http://your_server_ip:3838/. The sample output should be like this –


Hosting Interactive R Markdown Documents

At this point you should have a working Shiny Server that can host Shiny applications, but it cannot yet host interactive R markdown documents because the rmarkdown R package isn’t installed. Shiny Server comes with a sample interactive document that is available at

Shiny Server comes with a sample interactive document that is available at http://your_server_ip:3838/sample-apps/rmd/. If you go to that URL right now, you will see an error.


To fix the above problem, use the following command-

$ sudo su - -c "R -e \"install.packages('rmarkdown', repos='http://cran.rstudio.com/')\""

The sample output should be like this –

R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
...........................................................................................

Now, Shiny server is set up to run interactive R markdown documents as well as Shiny applications. To verify how interactive documents work, go to http://your_server_ip:3838/sample-apps/rmd/.

You now have a functioning Shiny Server that can host Shiny applications or interactive documents. The configuration file for Shiny Server is at /etc/shiny-server/shiny-server.conf. By default it is configured to serve applications in the /srv/shiny-server/ directory. This means that any Shiny application that is placed at /srv/shiny-server/app_name will be available to the public at http://your_server_ip:3838/app_name/.

After this article, you will be able to understand – How To Set Up Shiny Server on Ubuntu. In our next articles, we will come up with more Linux based tricks and tips. Keep reading!

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 20-Jan-2020

692 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements