Install Shiny Server for R on Ubuntu the Right Way

[This article was first published on R Tricks – Data Science Riot!, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Is it time to spin up a new instance of Shiny Server? This tutorial is baseed on a fresh install of Ubuntu Server 14.04, but I’m sure it could be tweaked to work on RHEL or CentOS as well. There’s no real secret sauce to the install but there are several “gotcha’s” that most people overlook. The walk-through below can get you up and running in just a few minutes.

1. Make sure you have the latest version of R.
If you don’t have the R environment on your box already. See here for the install.

sudo apt-get update && sudo apt-get upgrade

2. Install shiny package for R via command line.

sudo su - -c "R -e "install.packages('shiny', repos='')""

3. Make sure you have these dependencies.

sudo apt-get install -y libcurl4-openssl-dev 
sudo apt-get install -y libxml2-dev

…and don’t forget Java!

sudo apt-get install -y openjdk-7-jdk
export LD_LIBRARY_PATH=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server
sudo R CMD javareconf  

Change R package directory from user-based to system-wide. Find the below lines in your Renviron file and use your favorite text editor to swap the comment hashes to the configuration below.

sudo nano /usr/lib/R/etc/Renviron

Your Renviron file should look like this when you’re done.

5. Check lib paths in R to make sure your package library changed correctly.
“/usr/local/lib/R/site-library” should be the first of the library paths.


5. Make your new package lib readable for Shiny Server.

sudo chmod 777 /usr/lib/R/site-library

6. Install a few R packages.
It will ask if you want to create a personal directory, select “no.” You want them in the universal directory you just created.

install.packages(c('RJDBC', 'RJSONIO', 'rmarkdown', 'dplyr'))

7. Install Shiny Server.

sudo apt-get install -y gdebi-core
sudo wget
sudo gdebi shiny-server-

8. Set permissions for Shiny Server directory so outside users can see your apps.

sudo chmod -R 777 /srv

Open browser and point it to localhost:3838. Your Shiny Server should be started and running on port 3838!

To leave a comment for the author, please follow the link and comment on their blog: R Tricks – Data Science Riot!. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)