This article belongs to the series How to deploy a Shiny app on AWS, divided into 7 parts. To access the other articles, use the following table of contents:
- Part 1: Create a Shiny app.
- Part 2: Create an AWS server.
- Part 3: Install R and R Shiny on your new server.
- Part 4: Deploy the app on the server.
- Part 5: Extra: Create a nice domain name.
- Part 6: Extra: Secure your app with HTTPS.
- Part 7: Extra: Protect your app with a password.
Recently, a client asked me to create an app with R Shiny. This app was supposed to be used to visualize plenty of indicators and to interact with the data.
Rather basic for a Shiny app.
So I did my magic, created the dashboard, and the client was super happy!
Except… when he asked me to deploy it on his server.
That’s when things got complicated.
As a data scientist, writing an R script is a piece of cake. And since Shiny is getting more and more traction, I get more and more clients who ask me for automatic Shiny dashboards.
But the problem is when we need to host the app.
I need a server. I need to configure it. I need to update it. I need…
Well.. it’s not my job.
The “stupid” method
The first time I faced the issue, the team I worked with decided on a completely different solution.
We had no idea how to set up a server, nor the skills to do it anyway, so… we had to find another way.
It’s not pretty.
We installed R and the Shiny app on each user’s computer.
That’s what we did.
Every time we wanted to give access to a new user, we had to go to his desk, install R on his machine, the libraries, the data, create a shortcut on his desktop…
When you think about it, we were quite creative!
But also incredibly stupid…
- We still needed a way to share the data.
- It took forever to install the app for each user.
- It was hell to maintain.
But we had no choice.
No skills, and no help from the IT department.
Today, I know there exists a wayyy better solution.
The “smart” method
- Create a server in the cloud.
- Send the app there.
Ok, ok… I may be oversimplifying it.
It’s not that easy the first time.
But once you know how to do it, you can make it work in half an hour.
It is that simple.
And today, with this series of articles, my goal is to teach you exactly how to host a Shiny app on an AWS server.
So, where to start?
First, we’ll use AWS.
AWS is for Amazon Web Services, i.e. all the services from Amazon in the cloud.
Of course, you could use other services, such as Azure from Microsoft, Digital Ocean, Rackspace, etc.
But AWS is the most popular tool.
It’s a handy skill to have.
Plus: When you create a new account on AWS, you have free access to some services for a whole year.
Hence, everything we’ll do in these articles can be done for free.
The benefits of this smart method are:
- You can deploy the app without moving from your chair.
- It’s easy to maintain and update.
- You can upgrade your server at any time.
- You can customize security and user access.
What should you expect from this series?
My goal is to write an exhaustive guide so that every time you want to deploy a Shiny app, you can refer to these articles.
Until you remember exactly how to do it.
But I know from experience it’s easy to forget. So don’t hesitate to come back when you need.
I will explain each step with plenty of details, screenshots, drawings, maybe even videos!
The steps are:
- Step 1: Create a Shiny app
- Step 2: Create an AWS server
- Step 3: Install R and R Shiny on your new server
- Step 4: Deploy the app on the server
These steps are enough to get started!
But if you want to go further, I have created these new extra steps:
- Step 5: Create a domain name to have a nice URL
- Step 6: Secure your app with HTTPS
- Step 7: Protect your app with a password
And then we’ll be good!
Let’s start right away with step 1: Create a shiny app
Actually, it’s not exactly the goal of this article to teach you the Shiny framework.
So instead of spending time on that, let’s use an an app that already exists.
I chose the movie explorer from the Shiny gallery:
And I created a Gitlab repo that you can clone it easily: https://gitlab.charlesbordet.com/charles/051-movie-explorer
Note that you’ll need git and a console for this tutorial. You can download git here: https://git-scm.com
Ok, now we’re ready!
To continue to the next step, click here:
Leave a Comment
Required fields are marked *