R shinyserver:如何在闪亮的服务器上部署我的应用程序?

时间:2016-08-12 18:10:24

标签: r shiny-server

我已按照步骤在Red Hat Enterprise Linux Server 7.2版上设置闪亮服务器:

# path to my application on server
/home/anon/shinyapps/myapp/

myapp
├── R # Rscripts
├── data # R objects
├── server.R
├── ui.R
└── www
    └── styles.css

# install R
sudo yum update
sudo yum install R
sudo yum install libcurl-devel openssl-devel

# change Rprofile
sudo vi /usr/lib64/R/library/base/R/Rprofile

# add the following to the Rprofile
# download method
options(download.file.method = "libcurl")

# default CRAN mirror
local({
  r <- getOption("repos")
  r["CRAN"] <- "https://cran.rstudio.com/"
  options(repos=r)
})

# install shiny
sudo su - -c "R -e \"install.packages('shiny')\""

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

# edit config file
/etc/shiny-server/shiny-server.conf

这是我的配置文件。我将我的应用myapp添加到位置:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }

  # Define location at NWP URL
  location /NWP {

    # application directory
    app_dir /home/anony/shinyapps/myapp;

    simple_scheduler 10;

    # log directory
    log_dir /home/anon/shinyapps/myapp/logs;

    # directory structure
    directory_index on;
  }
}

我试图通过http://myserveraddress:3838/NWP/ This site can’t be reached来启动此应用程序。我错过了什么?

我尝试了什么:

$ sudo firewall-cmd --zone=public --permanent --add-port=3838/tcp && firewall-cmd --reload
success
Authorization failed.
Make sure polkit agent is running or run the application as superuser.

$ systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-08-05 10:44:34 EDT; 1 weeks 0 days ago
 Main PID: 1032 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─1032 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

这有效:

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

由于

1 个答案:

答案 0 :(得分:1)

这有效:

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