Shiny server working on Windows based virtual machine

Working in the NHS as I do, which runs all of its IT on Windows, I’d always despaired of being able to get Shiny Server working. However, I went to see the IT department and they have very kindly given me access to a virtual machine with Ubuntu 12.04.04 LTS running on it. It’s completely firewalled from the internet and is only visible from within the network, which is quite useful because it means I can put up things on it which are not for public consumption.

So the question was, will it run Shiny server without any problems? I’m very happy to say yes. This is a great development since it means I can run Shiny Server behind our corporate firewall and share things with people in the organisation with it very easily. Here’s a quick guide to what I did to get it working. I can’t say for sure if it will all work for you, depends on ports and probably lots of random other things, but it can’t hurt to try.

First job, of course, is to install R. Follow the link for a great summary of installing at the command line.

DON’T, as the Shiny Server documentation suggests, just run apt-get install r-base because the version in the repository is only 2.14 for which a lot of important packages are not available

I found on an NHS network that I had port problems, so instead of running:


gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9

Run this instead.


gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key E084DAB9

Worked for me anyway.

Now run:


sudo apt-get update

For me, this generated an error (again because of port problems):

GPG error: […] The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

So I ran this:


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 51716619E084DAB9

Now install:


sudo apt-get install r-base-dev

Now let’s install Shiny Server, follow the instructions here.

Boom. Navigate to 127.0.0.1:3838 (put your actual IP in here, obviously) and you should find the example application, give it a test, and you’re off.

Once you start running applications you will no doubt need to install R packages, I find it easier to launch R, run .libPaths() and make myself the owner of one of these directories:


sudo chown chrisbeeley /usr/lib/R/site-library/

That way you can just run install.packages(“ggplot2”) from within R rather than faffing around with R CMD INSTALL and all the packages will install into the site library.

Enjoy!

4 thoughts on “Shiny server working on Windows based virtual machine

  1. Hi!
    Thank you for the post.
    I’m in the exact same situation.
    I have the shiny server running in a virtual Linux server in my company.
    However, my problem is that the shiny applications use some R code that needs to access Windows SQL servers with windows authentication.

    Do you have any idea how can I solve this?

    Thank you!

    • Gosh, I really don’t know, I’m afraid. I’ve connected to MySQL instances on Linux servers, never tried Windows.

      The only thing I can think of is write an R script that pulls data from SQL and saves as .Rdata, get your IT people to run that for you nightly on Windows and then put the file somewhere your virtual server can get to. I do the same thing with mine, I don’t run the MySQL over Shiny because I don’t want the server to get overloaded with requests, easier to just use a .Rdata file.

      But you probably thought of that. Sorry I can’t be of more help.

  2. Hi,

    I just developed a shiny app, but I have some difficulties to host it online. I saw that you used a virtual machine working on windows. So, I wonder if the result is that you can get a web link shareable easily on internet, like for shinyapp.io? I mean without limitations of time or use. Because I look for an alternative to shinyapp.io, which is easy to use, but limited with the free account.
    Thank you for your understanding,
    Best Regards,

    Quentin

Leave a Reply