• Welcome to LiuJason's Blog!

CentOS8下安装和配置Rstudio-Server并使用Nginx实现SSL加密

Linux笔记 Jason 5 years ago (2020-02-17) 3385 Views 12 Comments
文章目录[隐藏]

前言

实在受不了国内容器云的访问速度,于是在德国节点打算新建一个Rstudio服务器自用。CentOS8出来也有一段时间了,就用新版的CentOS8试试水吧。

安装R的依赖环境

首先需要安装epel库:

yum install sudo wget -y && sudo yum install epel-release -y && yum update -y

安装Rstudio之前需要安装好R,这里偷懒就直接安装yum源里面的版本了,有需要的可以自行选择并编译安装:

sudo yum install R -y

这里出现了问题:

[root@rstudio ~]# sudo yum install R -y
Extra Packages for Enterprise Linux Modular 8 - x86_64                               59 kB/s |  40 kB     00:00    
Error: 
 Problem: package R-3.6.2-1.el8.x86_64 requires R-devel = 3.6.2-1.el8, but none of the providers can be installed
  - package R-devel-3.6.2-1.el8.x86_64 requires R-core-devel = 3.6.2-1.el8, but none of the providers can be installed
  - conflicting requests
  - nothing provides texinfo-tex needed by R-core-devel-3.6.2-1.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

发现是缺少了texinfo-tex,而这个包在CentOS8下的powertools repo中,而且并没有被默认开启,因此需要手动开启:

dnf install 'dnf-command(config-manager)' -y
sudo yum config-manager --set-enabled PowerTools

开启完成后再次安装R成功:

sudo yum install R -y

安装Rstudio

在官网下载最新版本的RstudioServer安装包:https://rstudio.com/products/rstudio/download-server/redhat-centos/
其中CentOS8和之前发行版本的不同,要注意下:

wget https://download2.rstudio.org/server/fedora28/x86_64/rstudio-server-rhel-1.2.5033-x86_64.rpm
sudo yum install rstudio-server-rhel-1.2.5033-x86_64.rpm -y

然后重启Rstudio-Server并设置开机启动:

systemctl restart rstudio-server
systemctl enable rstudio-server

此时应该可以在http://IP:8787访问Rstudio网页了

[root@rstudio ~]# lsof -i:8787
COMMAND  PID           USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
rserver 5579 rstudio-server    6u  IPv4 2446597      0t0  TCP *:msgsrvr (LISTEN)

使用Nginx转发实现SSL加密

Rstudio和Shiny都是需要使用到WebSocket的,因此需要在nginx里开启这个模块,具体可以参考:
https://www.liujason.com/article/529.html


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/530.html
Like (469)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(12)个小伙伴在吐槽
  1. 这样安装R 和 rstudio-server 这样在RHEL8.1 上安装后,server能起动,但是通过网页不能登录rstudio-server。[root@rstudio ~]# lsof -i:8787COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMErserver 5579 rstudio-server 6u IPv4 2446597 0t0 TCP *:msgsrvr (LISTEN)上面这行里的TCP *:msgsrvr (LISTEN)在我的RHEL8.1也是这样显示,通过网页不能登录rstudio-server。但是,同样的安装方式和安装文件在ubuntu 19.10就是完全正确的,而且在”TCP *:msgsrvr (LISTEN)“这个字段上不是 ”TCP *:msgsrvr (LISTEN)“了,而是”TCP *:8787 (LISTEN)“。 不知道你在CentOS8 上有没有通过网页登录一下试呢?
    job5602020-02-22 08:19 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
    • Jason
      你好,我试过了CentOS8下网页版登录无问题,可以正常使用。只不过有些包的依赖环境问题,暂时放弃使用CentOS8。你试试lsof -i:8787@访问的ip看看,有可能是监听的ip设置问题。
      Jason2020-02-22 16:30 Reply Mac OS X | 未知浏览器
  2. rhel 8.1系统:lsof -i:8787COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMErserver 2544 rstudio-server 6u IPv4 41939 0t0 TCP *:msgsrvr (LISTEN)ubuntu 19.1系统:COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMErserver 1194 rstudio-server 6u IPv4 43952 0t0 TCP *:8787 (LISTEN)
    job5602020-02-24 02:46 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
    • Jason
      我查了一下msgsrvr是8787端口的标准名称,你可以尝试改一下CentOS下的配置文件(/etc/rstudio/rserver.conf)把监听端口改成18787,再试试看能否正常使用。另外考虑下是不是防火墙规则没有设置好:firewall-cmd --zone=public --permanent --add-port 8787/tcp && firewall-cmd --zone=public --permanent --add-port 8787/udp && firewall-cmd --reload
      Jason2020-02-24 03:09 Reply Mac OS X | Chrome 79.0.3945.130
  3. rhel 8.1 ● rstudio-server.service - RStudio Server Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2020-02-24 23:19:03 CST; 5min ago Main PID: 45038 (rserver) Tasks: 3 (limit: 49637) Memory: 5.9M CGroup: /system.slice/rstudio-server.service └─45038 /usr/lib/rstudio-server/bin/rserver
    job5602020-02-25 00:08 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
  4. ubuntu 19.1● rstudio-server.service - RStudio Server Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2020-02-21 06:00:18 CST; 2min 45s ago Main PID: 1285 (rserver) Tasks: 3 (limit: 9452) Memory: 26.7M CGroup: /system.slice/rstudio-server.service └─1285 /usr/lib/rstudio-server/bin/rserver
    job5602020-02-25 00:09 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
  5. rhel 8.1 下通过网页登录,出错后,rstudio-server status 结果如下:● rstudio-server.service - RStudio Server Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2020-02-24 23:19:03 CST; 5min ago Main PID: 45038 (rserver) Tasks: 3 (limit: 49637) Memory: 5.9M CGroup: /system.slice/rstudio-server.service └─45038 /usr/lib/rstudio-server/bin/rserver2月 24 23:19:03 bioinfo systemd[1]: Starting RStudio Server...2月 24 23:19:03 bioinfo systemd[1]: Started RStudio Server.2月 24 23:22:03 bioinfo rserver[45273]: ERROR system error 13 (Permission denied); OCCURRED AT: rstudio::core::Error rstudio::core::system::launchChildProcess(std::__cxx11::string, std::__cxx11::string, rstudio::core::system::ProcessConfig, rstudio::core::system::ProcessConfigFilter, PidType*) /var/lib/jenkins/workspace/IDE/open-source-pipeline/v1.2-patch/src/cpp/core/system/PosixSystem.cpp:2152; LOGGED FROM: rstudio::core::Error rstudio::core::system::launchChildProcess(std::__cxx11::string, std::__cxx11::string, rstudio::core::system::ProcessConfig, rstudio::core::system::ProcessConfigFilter, PidType*) /var/lib/jenkins/workspace/IDE/open-source-pipeline/v1.2-patch/src/cpp/core/system/PosixSystem.cpp:2153
    job5602020-02-25 00:11 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
    • Jason
      网页登录后出错?也就是能看到rstudio-server的登录页面咯?那依次做以下操作试试看:
      • 1. 查看登录user的UID是否大于500
      • 2. 查看user的默认目录(一般在/home/username),是否存在
      • 3. 查看user的默认目录权限,使用ls -l
      • 4. 尝试用sudo启动rstudio-server
      Jason2020-02-25 00:19 Reply Windows 10 | Chrome 79.0.3945.130
      • 给出的建议都已经试过了,还是不行。在两个系统下执行 rstudio-server status 时有以下不同(行尾粗体部分):ubuntu 19.1 :rstudio-server.service - RStudio Server Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: enabled) rhel 8.1 : rstudio-server.service - RStudio Server Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: disabled)
        job5602020-02-25 01:41 Reply Windows 10 | Maxthon 浏览器5.2.7.5000
        • Jason
          嗯,刚刚回复前就注意到这个问题了,也查询过是permission问题。所以你能看到rstudio-server的登录页面吗?
          Jason2020-02-25 02:54 Reply Mac OS X | Chrome 79.0.3945.130
          • 能出现登录界面,但是连接时会跳出错误窗口,显示 “rstudio initialization error” “unable to connection to service ”
            job5602020-02-26 04:21 Windows 10 | Maxthon 浏览器5.2.7.5000
          • SELinux 的问题!
            job5602020-02-28 03:29 Windows 10 | Maxthon 浏览器5.2.7.5000