Linux安装,卸载R服务及Rstudio。
我是root用户,环境是CentOS-7-x86_64-Everything-1611.iso。
查看系统版本
cat /proc/version
Linux系统分为两种:
1.RedHat系列:Redhat、Centos、Fedora等
2.Debian系列:Debian、Ubuntu等
RedHat系列的包管理工具是yum
Debian系列的包管理工具是apt-get
我这里是yum
首先安装R服务。
(1)安装依赖 yum -y install gcc glibc-headers gcc-c++ gcc-gfortran readline-devel libXt-devel bzip2-devel xz-devel perl* pcre* zlib-devel libcurl-devel
(2)安装R wget http://cran.rstudio.com/src/base/R-3/R-3.4.2.tar.gz tar -zxvf R-3.4.2.tar.gz cd R-3.4.2 mkdir /usr/local/R ./configure --enable-R-shlib=yes --with-tcltk --prefix=/usr/local/R make make install (3)配置环境变量 全局配置: vi /etc/profile #add R env R_HOME=/usr/local/R PATH= P A T H : PATH: PATH:R_HOME/bin export PATH
linux–修改完profile文件后让他立马生效: source /etc/profile
(4)安装好以后查看R版本 sudo -i R 表示安装成功。
安装Rstudio-Serve
下载版本: wget http://download2.rstudio.org/rstudio-server-rhel-0.99.903-x86_64.rpm 安装: sudo yum install --nogpgcheck rstudio-server-rhel-0.99.903-x86_64.rpm 查看是否安装正确 sudo rstudio-server verify-installation
如果找不到R服务: Unable to find an installation of R on the system (which R didn’t return valid output); Unable to locate R binary by scanning standard locations
执行 which R 找到你的R的安装目录
需要配置一下: cd 到/etc/rstudio/rserver.conf www-port=8787
rsession-which-r=R语言的安装目录/bin/R
重启即可。
通过浏览器访问Rstudio IP为:http://<服务器ip>:8787 这里需要我们输入用户名和密码。关于用户名有2点注意事项: (1).不允许使用system 用户登陆,即用户ids小于100的用户。只能用普通用户登录 (2).用户的认证可以使用RSA。 如果没有普通用户,可以添加: useradd newname # 添加一个名为newname的用户 passwd newname ###给新用户newname 设置密码,密码需是复杂密码,否则可能通不过。 usermod -G happy newname ####将新用户newname添加到happy 用户组中
一些命令
完成安装后,RStudio Server会自动启动运行 ps -aux|grep rstudio 8787端口被打开
启动Rstudio-server rstudio-server start #启动 rstudio-server stop #停止 rstudio-server restart #重启
查看运行中R进程 rstudio-server active-sessions
指定PID,停止运行中的R进程 rstudio-server suspend-session
停止所有运行中的R进程 rstudio-server suspend-all
强制停止运行中的R进程,优先级最高,立刻执行 rstudio-server force-suspend-session rstudio-server force-suspend-all RStudio Server临时下线,不允许web访问,并给用户友好提示 rstudio-server offline RStudio Server临时上线 rstudio-server online
R中的一些有帮助解决安装问题的命令:
R.home() ## 查看R的安装目录 R.Version()[13] ## 查看R版本 Sys.getenv(“R_HOME”) .Library ##查看lib位置 .libPaths() ##查看lib位置
卸载R的方法:
yum list installed | grep R R.x86_64 2.15.2-1.el5 installed R-core.x86_64 2.15.2-1.el5 installed R-devel.x86_64 2.15.2-1.el5 installed yum remove R.x86_64 yum remove R-core.x86_64
卸载rstudio
//名称和简介匹配 only,使用“search all”试试。 yum list |grep ‘rstudio’
//卸载 yum remove rstudio-server.x86_64 -y
