Install RStudio Shiny Server on Centos 7

By Sajid Qureshi, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Shiny Server is a web server which provides you with a platform to host R-powered shiny application on the server. You can host multiple shiny applications on a single server without getting HTML, CSS, and other stuff involved. It enables you to support non-web socket-enabled browsers like Internet Explorer 10.

Some of the features of the Shiny server are listed below:

  1. Free and open source
  2. Host multiple Shiny applications, each with its own URL
  3. Can be configured to allow any user on the system to create and deploy their own Shiny applications
  4. Pre-built installers for select Linux distributions.

Prerequisites

  1. Root user privileges

In this article, we are using root user to install Shiny server on an Alibaba Cloud Elastic Compute Service (ECS) instance. you can also switch from non-root user to root user using sudo -i command.

Update the System

Install R

Next, install R.
yum -y install R

You’ll also need to install the Shiny R package and some other dependencies before installing Shiny Server:
su - -c "R -e \"install.packages(c('shiny', 'rmarkdown', 'devtools', 'RJDBC'), repos='http://cran.rstudio.com/')\""

The above command will take a few minutes, so hold on a bit. You should see something similar to this output in the end.

Image for post
Image for post

Install Shiny Server

Next, install the downloaded shiny server using the following command.
yum install --nogpgcheck shiny-server-1.5.7.907-rh6-x86_64.rpm

You’ll see the following output at the end.

Image for post
Image for post

If you see the above-given output then the Shiny server is successfully installed on your CentOS 7 system. Now you’ll need to start and enable the shiny server services. Execute the following commands and they’ll do the job for you.

systemctl start shiny-server
systemctl enable shiny-server

Finally, you’ll need to modify the firewall rules for your Shiny server to access it. Shiny server listen to port number 3838 by default.
firewall-cmd --permanent --zone=public --add-port=3838/tcp
firewall-cmd --reload

Web Interface

Image for post
Image for post

(NOTE: Replace YourServerIP with your actual server IP address.)

Host a Directory of Applications

For example, suppose you have a directory of application called ‘myApp’. This directory should be stored in the default directory of shiny server like /srv/shiny-server/myApp. Now you can access your application on http://YourServerIP:3838/myApp . HTML files also can be placed in this directory and you can access them from Shiny Server.

Manage Your Own Applications

For example, suppose you stored your shiny application in /home/user/ShinyApps/myApp then your new application is available on http://YourserverIP:3838/YourLinuxUsername/myApp .

Conclusion

Reference:

https://www.alibabacloud.com/blog/install-rstudio-shiny-server-on-centos-7_593995?spm=a2c4.12036690.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store