Linux

無法通過瀏覽器訪問 CentOS 7 上的 RStudio 伺服器

  • November 8, 2018

我有一個x86_64系統正在執行CentOS 7。我已經安裝並配置 RRStudio Server它,但無法http://<server-ip>:8787按照此處文件的建議訪問它。我收到以下錯誤Google Chrome

This site can’t be reached
<server-ip> refused to connect.
Search Google for 206 196 8787
ERR_CONNECTION_REFUSED

我嘗試並驗證了許多網路、防火牆設置。但是,似乎沒有任何效果。

R在系統上工作

~$ R
R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> print("I Work")
[1] "I Work"

RStudio Server 已配置並處於活動狀態

~$ sudo rstudio-server verify-installation
~$ sudo rstudio-server status
● rstudio-server.service - RStudio Server
  Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: disabled)
  Active: active (running) since Sat 2017-10-21 21:33:53 MST; 1s ago
 Process: 8300 ExecStop=/usr/bin/killall -TERM rserver (code=exited, status=0/SUCCESS)
 Process: 8346 ExecStart=/usr/lib/rstudio-server/bin/rserver (code=exited, status=0/SUCCESS)
Main PID: 8349 (rserver)
  CGroup: /system.slice/rstudio-server.service
          └─8349 /usr/lib/rstudio-server/bin/rserver

Oct 21 21:33:53 localhost.localdomain systemd[1]: Starting RStudio Server...
Oct 21 21:33:53 localhost.localdomain systemd[1]: Started RStudio Server.
~$ sudo rstudio-server restart
rsession: no process found
~$ sudo rstudio-server start
~$ sudo rstudio-server stop
rsession: no process found
~$ sudo rstudio-server start
~$ sudo rstudio-server status
● rstudio-server.service - RStudio Server
  Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: disabled)
  Active: active (running) since Sat 2017-10-21 21:34:14 MST; 2s ago
 Process: 8449 ExecStop=/usr/bin/killall -TERM rserver (code=exited, status=0/SUCCESS)
 Process: 8477 ExecStart=/usr/lib/rstudio-server/bin/rserver (code=exited, status=0/SUCCESS)
Main PID: 8480 (rserver)
  CGroup: /system.slice/rstudio-server.service
          └─8480 /usr/lib/rstudio-server/bin/rserver

Oct 21 21:34:14 localhost.localdomain systemd[1]: Starting RStudio Server...
Oct 21 21:34:14 localhost.localdomain systemd[1]: Started RStudio Server.

netstat 輸出顯示埠可以監聽

~$ netstat -nat | grep LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8787            0.0.0.0:*               LISTEN
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp6       0      0 :::111                  :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:631                 :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

防火牆說埠是開放的

~$ sudo ufw allow 8787
~$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
SSH                        ALLOW       Anywhere
224.0.0.251 mDNS           ALLOW       Anywhere
8787                       ALLOW       Anywhere
SSH (v6)                   ALLOW       Anywhere (v6)
ff02::fb mDNS              ALLOW       Anywhere (v6)
8787 (v6)                  ALLOW       Anywhere (v6)

系統控制輸出

~$ sudo 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 Sat 2017-10-21 20:38:02 MST; 35min ago
Docs: man:firewalld(1)
Main PID: 2987 (firewalld)
CGroup: /system.slice/firewalld.service
       └─2987 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

~$ sudo firewall-cmd --zone=public --add-port=8787/tcp
Warning: ALREADY_ENABLED: '8787:tcp' already in 'public'
success
~$ sudo firewall-cmd --reload
success   
~$ sudo firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp4s0f1
sources:
services: dhcpv6-client ssh
ports: 8787/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

誰能幫我指出我哪裡出錯了?

謝謝。

我不確定什麼有效,什麼無效,但以下步驟有所幫助。有關這方面的更多詳細資訊,請參閱RStudio 社區支持

步驟

  1. apache從系統解除安裝。
  2. 將 /etc/rstudio/rserver.conf編輯為

www-port=8787 www-address=<server-ip> 3. 執行sudo rstudio-server restart 4. RStudio Server 可通過瀏覽器訪問。

此外,即使沒有inRStudio Server也可以訪問。www-address=<server-ip>``/etc/rstudio/rserver.conf

注意Apache今天本身已配置為僅測試是否至少可以通過瀏覽器訪問 Web 伺服器。

引用自:https://serverfault.com/questions/879660