Set Up Shiny-server on

April 23, 2014

(This article was first published on Category: R | Huidong Tian's Blog, and kindly contributed to R-bloggers)

RStudio supplies several servers for hosting user’s apps, e.g.,, Thanks a lot to RStudio who has contributed many excellent R libraries! I want to set my shiny-server on a virtual private server (VPS), because I have some other tasks and I feel a VPS is more stable than the PC under my desk.

Setting up a Shiny-server on Digital Ocean is easy, follow this blog you can get your shiny-server work in 10 minutes.

  • Create a Droplet
    First, register an account on Digital Ocean. Log in and register Billing details, then you are ready to create your first Droplet (server). Give your droplet a name, select its size, region, image (I prefer Ubuntu 12.04.4) and then click Create Droplet. In one minute, your droplet will be created, and you will receive an email containing the IP address, username and password of your server.

  • Remote control
    Users can access their server using the Console of Digital Ocean’s webpage, but there are a lot limitation. It’s much easy to control your server using local terminal console. Under Windows, I recommend to use Putty. Download and install Putty. Open it, set the IP address and Saved Sessions, then click Open to open Putty’s console.

Login Putty use the username and password in your email. After log in, please change your password first using command passwd.

  • Install R and shiny package

For security reason, add R’s secure APT key to system:

“` ruby
sudo apt-key adv –keyserver –recv-keys E084DAB9


Add this repository

deb precise/

to the end of sources.list to ensure the R that will be installed consistent with your system version:

sudo nano /etc/apt/sources.list

Update and install R:

sudo apt-get update
sudo apt-get install r-base r-base-dev

Install shiny package:

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

  • Install Shiny-server

“` ruby
sudo apt-get install gdebi-core
sudo gdebi shiny-server-


If anything is OK, you can now access your shiny-server by typing your server’s IP address: 3838.

  • Install RStudio-server
    Putty is convenient for remotely control your sever, but not intuitive for documents management. RStudio-server is one excellent solution for R project management and file transfer. Use the following commands to install RStudio server on your droplet:

sudo apt-get install gdebi-core
sudo apt-get install libapparmor1 # Required only for Ubuntu, not Debian
sudo gdebi rstudio-server-0.98.507-amd64.deb

Due to RStudio Server will not permit logins by system users, so we need add a non-system user to our droplet, for example, I want to add a user named withr:

adduser withr

Set the privilege of the user as equal to root will avoid many troubles!


Add line withr ALL=(ALL:ALL) ALL after root ALL=(ALL:ALL) ALL , like the following:

# User privilege specification

Save the edition.

Now, we can access the RStudio server through IP:8787 using withr and its password.

To leave a comment for the author, please follow the link and comment on their blog: Category: R | Huidong Tian's Blog. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.