由于RHEL 7系统中,采用firewalld防火墙去掉了传统的iptables防火墙,因此对于安装Rstudio-server会与RHEL 6系统或者Ubuntu不同,安装Rstudio之后,其他设备是无法通过网络登录Rstudio的,这就需要修改防火墙,本次推文,我们将详细介绍如何在RHEL 7系统,包括CentOS系统中,安装和使用Rstudio-server。

安装R

在RHEL 7中安装R比Ubuntu系统中要容易很多,虽然Ubuntu中可以利用apt安装r-base,但是这个R的版本并不是最新版的,在RHEL 7中,只需要添加epel源,就可以直接通过yum安装最新版的R。

yum install -y epel-release
yum install -y R

安装Rstudio

这里选择下载安装免费版的Rstudio-server,我们选择使用RedHat/CentOS系统64位版本的rpm包。
链接地址:https://www.rstudio.com/products/rstudio/download-server/
注意必须使用管理员root账户安装。

centos7怎么装r语言(7系统如何安装Rstudio-server)(1)

#安装Rstudio
wget https://download2.rstudio.org/rstudio-server-rhel-1.1.463-x86_64.rpm
sudo yum install rstudio-server-rhel-1.1.463-x86_64.rpm

校验安装是否成功

$ rstudio-server verify-installation
$ rstudio-server status

修改防火墙

默认防火墙是关闭8787窗口,需要手动开启这个端口,RHEL 7系统采用systemctl命令来进行处理。

systemctl enable rstudio-server.service
systemctl start rstudio-server.service
systemctl status rstudio-server
firewall-cmd --permanent --add-port=8787/tcp
firewall-cmd --permanent --add-port=8787/udp
firewall-cmd --reload

重启Rstudio-server

$ rstudio-server
Usage: rstudio-server {status|start|stop|restart|test-config|verify-installation|suspend-session|suspend-all|force-suspend-session|force-suspend-all|kill-session|kill-all|offline|online|active-sessions|version}

$ rstudio-server restart

通过浏览器登录Rstudio

不能使用管理员账户登录Rstudio,这是因为root账户读写权限太大,会把系统目录写的很乱,因此很多程序禁止使用管理员账户使用。

centos7怎么装r语言(7系统如何安装Rstudio-server)(2)


,