CentOS 下 R 的安裝

guoge發表於2016-07-28
 

相比Windows 下的安裝,Linux 作業系統中可以使用原始碼安裝,由於相關元件的依賴性,所以安裝起來會麻煩點, 但由於網路上資料甚多,因此也不太複雜。

一、R 語言環境的安裝

1. 下載R的原始碼,可以在 ,獲取最新版的R 程式碼,寫文件的時候,版本為R-3.3.0

wget

2. 解壓

Cd /usr/

tar -zxvf R-3.3.0.tar.gz

cd R-3.3.0

3. 安裝一些依賴包和配置

sudo yum install readline-devel

sudo yum install libXt-devel

./configure  --enable-R-shlib --prefix=/usr/ R-3.3.0 --with-readline=yes --with-libpng=yes

在實際過程中,由於CentOS  環境不同, 還需安裝其它一些包,否則configure 會出現一系列報錯, 當出現問題時, 執行相應命令後,可再執行上面的configure 命令  例如:

當出現:

 configure: error: C++ preprocessor /lib/cpp sanity check

check See `config.log for more details

這可能是由於c++編譯器的相關package沒有安裝,執行:

sudo yum install glibc-headers gcc-c++

如果不放心,也可加上:

sudo yum install build-essential

當出現:

configure: WARNING: you cannot build PDF versions of the R manuals

configure: WARNING: you cannot build PDF versions of vignettes and help pages

configure: WARNING: you cannot build info or HTML versions of the R manuals

可執行:

sudo  yum  install texinfo

sudo   yum install texlive

當出現:

configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally

configure: error: bzip2 library and headers are required

可執行:

 sudo yum  install bzip2-devel

sudo  yum  install bzip2-libs

當出現

WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally

執行:

wget

解壓 Unzip inconsolata.zip

將檔案複製到目錄下:

        cp -Rfp inconsolata/* /usr/share/texmf/

 重新整理sty

        Mktexlsr

當出現:

configure: error: "liblzma library and headers are required"

執行:

sudo  yum -y install xz-devel.x86_64

當出現:

configure: error: pcre >= 8.10 library and headers are required

執行:

sudo  yum install pcre-devel.x86_64  pcre-static.x86_64 pcre-tools.x86_64 pcre.x86_64

當出現:

configure: error: libcurl >= 7.28.0 library and headers are required with support for https

執行:

sudo  yum install  libcurl-devel.x86_64 libcurl.x86_64

以下是我沒遇到但其它材料提到的:

# sudo  yum install gcc-gfortran              #否則報”configure: error: No F77 compiler found”錯誤

# sudo  yum install gcc gcc-c++              #否則報”configure: error: C++ preprocessor /lib/cpp fails sanity check”錯誤

# sudo  yum install readline-devel          #否則報”–with-readline=yes (default) and headers/libs are not available”錯誤

# sudo  yum install libXt-devel                 #否則報”configure: error: with-x=yes (default) and X11 headers/libs are not available”錯誤

4. 編譯和安裝

make

make install

make 過程中,如果出現Unable to compile a JNI program 忽略,目前還沒遇到問題

5環境配置

為了能在任何環境下執行R ,有兩種方法,一是

vi .bash_profile

PATH=/usr/R-3.0.1/bin

二是ln -s /usr/R-3.3.0/bin/R /usr/local/bin/R

6 . 測試

輸入R  看是否可以出現命令列視窗

二、 配置R Studio Server

1.  安裝

$ wget

$ sudo yum install --nogpgcheck rstudio-server-rhel-0.99.903-x86_64.rpm

在本地執行:   看是否可以出現登入介面, 可以使用linux 中自定義的使用者來登入

2. 開啟防火牆

$ sudo firewall-cmd --zone=public --add-port=8787/tcp --permanent

$ sudo firewall-cmd –reload

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9036/viewspace-2122686/,如需轉載,請註明出處,否則將追究法律責任。

相關文章