Here you can see a guide to create and account and configure it:
http://www.exegetic.biz/blog/2015/05/hosting-shiny-on-amazon-ec2/
To this end, you need to write:
$ chmod 400 yourkey.pem
$ ssh -i "yourkey.pem" ubuntu@ec2-54-229-255-18.eu-west-1.compute.amazonaws.com
Then you need to install R, Shiny, etc.:
$ sudo apt-get update
$ sudo apt-get install r-base
$ sudo apt-get install r-base-dev
$ sudo su - \
-c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
$ sudo su - \
-c "R -e \"install.packages('fpp', repos='https://cran.rstudio.com/')\""
$ sudo su - \
-c "R -e \"install.packages('rmarkdown', repos='https://cran.rstudio.com/')\""
$ sudo su - \
-c "R -e \"install.packages('ggplot2', repos='https://cran.rstudio.com/')\""
$ sudo apt-get install gdebi-core
$ wget https://download3.rstudio.org/ubuntu-12.04/x86_64/shiny-server-1.5.5.872-amd64.deb
$ sudo gdebi shiny-server-1.5.5.872-amd64.deb
hint: you need to rewrite the version number of the shiny-server with the last one (https://www.rstudio.com/products/shiny/download-server/)
We can test the shiny-server. In order to do this, we need:
- to install a sample app
$ sudo /opt/shiny-server/bin/deploy-example default
- to open the port, so your Shiny server can be accessed from the outside world. By default, this is port 3838. Go to Instances, select your instance, and then click on the Security Group in the instance’s detail section. Click on the Inbound tab. By default, AWS instances launched with the wizard have only port 22 open, which is needed to SSH in. No wonder we cannot access our instance! Click on Edit and add a custom TCP rule to open port 3838 from anywhere.
Open your favorite browser and enter the following address:
http://ec2-54-229-255-18.eu-west-1.compute.amazonaws.com:3838/sample-apps/hello/
hint: replace the IP address (ec2-54-229-255-18.eu-west-1.compute.amazonaws.com, in my example) with the address of your instance, which is the same with which you connected to your instance.
If you want users don't specify the number of the port (3838), you can change it to 80 in the shiny configuration. For this:
$ sudo nano /etc/shiny-server/shiny-server.conf
and change the number 3838 by 80, press Ctrl + X and Yes. Lastly, you need to restart the server
$ sudo systemctl restart shiny-server
and open your port 80 in the AWS EC2 Security Group by adding a custom TCP rule for port 80, similar to what you did above for 3838.
Note: To write this section I've used a modified version of the text on https://ipub.com/shiny-aws/
Finally, you can see here an example:
http://ec2-54-229-255-18.eu-west-1.compute.amazonaws.com/shiny_npregfast/
- Copying folders from my computer to the server:
$ scp -r /Users/Sestelo/Dropbox/github/shiny_npregfast/ ubuntu@ec2-54-229-255-18.eu-west-1.compute.amazonaws.com:~
$ scp -r /Users/Sestelo/Dropbox/github/shiny_npregfast/ ubuntu@ec2-54-229-255-18.eu-west-1.compute.amazonaws.com:/srv/shiny-server/
- Moving files (server):
$ sudo mv /home/ubuntu/shiny_npregfast/ /srv/shiny-server/
- Installing R packages in the server (in order to shiny apps work well). If you install them from console, the apps aren´t going to work because it install them in your local library (rstudio/shiny#862):
$ sudo su - -c "R -e \"install.packages('npregfast', repos='http://cran.rstudio.com/')\""
The yourkey.pem file must be in the user folder (/Users/Sestelo/yourkey.pem)
In terminal, type:
$ chmod 700 yourkey.pem
$ ssh-add -K yourkey.pem
In Transmit (use SFTP) fill with:
- server: the name of the domain used to access it (ec2-54-229-255-18.eu-west-1.compute.amazonaws.com)
- username: ubuntu
- the rest: nothing