Install R Shiny Server on CentOS 7
We look at how to install R, a popular language for data science, and get it running on the open source Linux distribution, CentOS.
Join the DZone community and get the full member experience.Join For Free
The shiny server is a web server which provides you with a platform to host R-powered shiny applications 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:
- Free and open source.
- Host multiple Shiny applications, each with its own URL.
- Can be configured to allow any user on the system to create and deploy their own Shiny applications.
- Pre-built installers for select Linux distributions.
- You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to set up your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
- Root user privileges.
In this article, we are using root user to install Shiny server. You can also switch from non-root user to root user using
sudo -i command.
Update the System
It is recommended to install any package on a freshly updated system. So, first upgrade all the available packages using the following command.
yum -y install update
An R package is required to install the Shiny server so we need to install R. Before installing the R package, you’ll have to add EPEL repository to your CentOS 7 system. Execute the following command and it’ll do the job for you.
yum install epel-release
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.
Install Shiny Server
All the dependencies required for the Shiny server are installed now and we are ready to install it on CentOS 7. So let’s download the latest stable release of the Shiny server using the following command.
Next, install the downloaded shiny server using the following command.
yum install --nogpgcheck shiny-server-220.127.116.117-rh6-x86_64.rpm
You’ll see the following output at the end.
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
Open up your favorite web browser and visit http://YourServerIP:3838/ then you’ll see a welcome webpage of Shiny server like this:
(NOTE: Replace YourServerIP with your actual server IP address.)
Host a Directory of Applications
Shiny Server allows you to host a directory of the shiny application. By default, Shiny Server will use a
site_dir to make any applications and assets stored in
/srv/shiny-server/ available. Place your directory of shiny applications in the default directory.
For example, suppose you have a directory for an 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
You can manage your shiny applications and update your applications stored in the home directory. All the shiny applications are hosted inside the user’s ShinyApps directory.
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 .
In this article, you’ve learned how to install Shiny Server on your CentOS 7 server. You’ve also learned to host a directory of applications and managing your own applications. We hope now you have enough knowledge to work with Shiny Server.
Published at DZone with permission of Sajid Qureshi. See the original article here.
Opinions expressed by DZone contributors are their own.