How to Install Shiny Server on CentOS 7

Shiny Server is a web server program specifically designed to host R-powered Shiny apps. With Shiny Server, you can easily host various R-powered apps without getting HTML, CSS, JavaScript or other stuff involved.

This article will guide you through the process of installing Shiny Server on a CentOS 7.

Prerequisites

  • A VM Running CentOS 7 ( minimal install ).
  • A sudo user with log in access.

Step 1: Update the system and packages for commonly used R

sudo yum install epel-release
sudo yum update

yum install openssl-devel
yum install cyrus-sasl-devel
yum install libxml2-devel
yum install postgresql-devel 
yum install libcurl-devel

sudo shutdown -r now

After the reboot, log in again as the same sudo user.

Step 2: Install R

sudo yum install R

Step 3: Install a few commonly used R packages, including shiny

sudo su - -c "R -e \"install.packages(c('shiny', 'rmarkdown', 'devtools', 'RJDBC','DT'), repos='http://cran.rstudio.com/')\""

sudo su - -c "R -e \"install.packages(c('DT','mongolite','shinyjs','data.table','tidyverse','RPostgreSQL','pool'), repos='https://cran.rstudio.com/')\""

or :

sudo su - -c "R -e \"install.packages('DT', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('mongolite', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('shinyjs', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('data.table', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('tidyverse', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('RPostgreSQL', repos='https://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('pool', repos='https://cran.rstudio.com/')\""

If you need more R packages, you can install them in the same fashion.

Step 4: Install and start Shiny Server

Download and install Shiny Server:

cd
wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.4.2.786-rh5-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.4.2.786-rh5-x86_64.rpm

Note: The above wget download URL is up to date at the time of writing. You can always confirm the latest URL from the Shiny Server Download Page .

Start Shiny Server:

sudo systemctl start shiny-server
sudo systemctl enable shiny-server

Step 5: Modify firewall rules

To allow people to use your Shiny apps, you need to modify firewall rules as below:

sudo firewall-cmd --permanent --zone=public --add-port=3838/tcp
sudo firewall-cmd --reload

Step 6: Access Shiny Server from a browser

Now, you can open the following URL from your browser:

http://<your-Vultr-server-IP>:3838/

If all goes well, you would see the Shiny Server welcome page. On the right side of this page, you should also see a Shiny app and a Shiny Doc.

That concludes our tutorial. Thank you for reading.