美文网首页js css html
CentOS 7安装R和Rstudio的方法2

CentOS 7安装R和Rstudio的方法2

作者: 可能性之兽 | 来源:发表于2022-12-22 14:54 被阅读0次

    方法1在这里
    CentOS 7安装R和Rstudio - 简书 (jianshu.com)

    相比于上面那个方法,这个方法更烦琐,需要解决的依赖和报错更多(可能多到你怀疑人生),没有上面那个方法爽利,但是这个方法有个好处(理论上第一个方法应该也能做到,只是需要的探索我还不清楚)

    R的安装

    (1)安装依赖

    有些依赖需要由于centos的yum那里版本太低,可能需要自己手动安装和编译,比较繁琐

    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-4/R-4.1.0.tar.gz
    tar -zxvf R-4.1.0.tar.gz
    cd R-4.1.0
    mkdir /usr/local/R
    ##./configure --enable-R-shlib=yes --with-tcltk --prefix=/usr/local/R
    ./configure --enable-R-shlib --with-pcre1 --with-blas --enable-lapack --prefix=/usr/local/R-4.1.0  
    make
    make install
    

    (3)配置环境变量 全局配置:

    
    vi /etc/profile
    #add R env
    export PATH=/usr/local/R-4.1.0/bin:$PATH 
    ### 说明:R不一定是在/usr/local/R-4.1.0/bin里面,需要自己找一下
    source /etc/profile
    

    rstudio

    wget https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-2022.07.2-576-x86_64.rpm
    sudo yum install rstudio-server-rhel-2022.07.2-576-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
    
    

    默认浏览器为8787这个端口,如果发现打不开,说明防火墙的设置有问题(解决详见我写的防火墙那一篇文章),需要设置一下,或者如上所示更改你的端口

    卸载R和rstudio

    卸载R的方法:
    yum list installed | grep R
    
    ## 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
    
    

    当然还有方法3,比如通过docker之类的进行安装

    参考

    https://blog.csdn.net/u010797364/article/details/10904683

    服务器centos8.3安装R和Rstudio

    rstudio server包的安装位置

    相关文章

      网友评论

        本文标题:CentOS 7安装R和Rstudio的方法2

        本文链接:https://www.haomeiwen.com/subject/pgmvqdtx.html