Extension:Shiny/CentOS 7

From Linux Web Expert

For installing the Shiny extension are three or four steps are necessary:

  1. Install a current R version
  2. Install the Shiny server
  3. Install the Shiny extension
  4. Optionally tweak the Apache configuration

For all steps it is assumed that a LAMP server and MediaWiki is installed and you are logged in as root.

Additionally steps might be necessary if SELinux is activated, see in /etc/selinux/config if is set SELINUX=enforcing. To avoid these steps you could deactivate SELinux by setting SELINUX=disabled and reboot.

R

R is not part of the standard repositories in CentOS 7, but part of the Extra Packages for Enterprise Linux (EPEL). How to add the EPEL repository to your CentOS 7 installation, see in the EPEL FAQ: How can I install the packages from the EPEL software repository?. Then run

 yum install R

After that R should have been installed.

Shiny server

  • Install the shiny package in R
R -e "install.packages('shiny', repos='https://cran.rstudio.com/')"
wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.4.2.786-rh5-x86_64.rpm
  • Install the Shiny server to your system
yum install --nogpgcheck shiny-server-1.4.2.786-rh5-x86_64.rpm
  • To check if the shiny server works enter in your browser: http://<my.domain>:3838
  • Add a path and permissions to store the shiny apps
cd /srv/shiny-server
mkdir mediawiki
chown apache:apache mediawiki

MediaWiki

  • Hint: For the correct installation of the MediaWiki you need to install php-xml in CentOS 7 and to restart the Apache web server
 yum install php-xml
 systemctl restart httpd.service
  • After the installation of your wiki go to the extensions directory
cd <my.wiki>/extensions
  • If necessary then install git
yum install git
  • Clone the Shiny extension from github.com
git clone https://github.com/sigbertklinke/Shiny
  • Edit your <my.wiki>/LocalSettings.php and add at the end
wfLoadExtension( 'Shiny' );

Apache

The Apache webserver listens to port 80 and the Shiny server to port 3838. Usually I modify the Apache configuration file such that any URL with starts with http://<my.domain>/shiny/ is redirected to the Shiny server:

  • Go to the Apache configuration directory
cd /etc/httpd/conf.d
  • Create a configuration file reverse-proxy.conf with
 <IfModule mod_proxy.c>
   ProxyRequests Off
   <Proxy /shiny/>
     Require local
   </Proxy>
   ProxyPass        /shiny/ http://localhost:3838/
   ProxyPassReverse /shiny/ http://localhost:3838/
 </IfModule> 
  • If SELinux is active then you need to allow then Apache web server to make outbound connections with
 /usr/sbin/setsebool -P httpd_can_network_connect 1 
  • Restart the apache server
systemctl restart httpd.service
  • To check if this works properly enter in your browser: http://<my.domain>/shiny/ (and when you enter http://<my.domain>:3838/ you should see the same page)

External links