背景
LAMP搭建的网站在ubuntu14.04,有用户文件上传和下载,后台程序以R脚本运行为主,本机安装的R为3.4.4,需要安装最新3.6 搭配最新的R包。本来想着用conda来安装,但是 apahce无法找到R执行文件,因此还得重新全局安装,要有网。我的ubuntu 使用代理上网,因此遇到了一些问题:
问题和解答
1.添加ubuntu中R的软件源:
ubuntu14.04 默认安装的就是 R.3.4.4,我使用的是中科大的CRAN源 ubuntu14.04版本
vi /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu/ trusty-cran35/
sudo apt-get update
末尾添加 trusty-cran35搭配的是14.04版本的ubuntu系统,其他见 USTC-CRAN 中的其他目录,其中trusty与 trusty-cran的区别是前者R的最高版本就是R3.4.4,而后者是一直更新到最新版本。
在更新的时候可能出现以下报错(这里是复制其他版本的ubuntu的报错信息):
root@ubuntu:~# apt-get update
Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Could not resolve 'security.ubuntu.com'
Err:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Could not resolve 'us.archive.ubuntu.com'
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Could not resolve 'us.archive.ubuntu.com'
Err:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
Could not resolve 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial/InRelease Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@ubuntu:~#
这是apt-get update 没有利用 代理上网 而导致的网络不通的报错,解决参考unixmen 如下:
# Create new conf empty file inside /etc/apt/ and do the following
sudo vi /etc/apt/apt.conf
# add this line to the file if you are using http proxy else https of ftp:
Acquire::http::Proxy "http://proxy_host:port";
# 代理也已经写入用户家目录的环境变量 .bashrc
vi ~/.bashrc
export http_proxy="http://proxy_host:port"
apt-get update # 成功
apt-get install r-base # 安装的就是目前的最新版3.6.3 ,
2.安装R包
install.packages("") # 在线安装
install.packages("",repos=NULL) # 本地安装
安装相关R包的时候。比如DESeq2包的时候,如果出现因为哪个包没安装好,最后肯定是与R包相关的,但是是ubuntu的软件或者库没有安装好,比如 依赖 XML 和 RCurl 两个包就是因为 ubuntu没有 安装libxml2-dev 和 libcurl4-openssl-dev,参考 1 2 。只要不是ubuntu的库没安装好,那么安装DESeq2的时候其他依赖包也会同时安装好的。所以只要看好安装失败的报错信息,google以下就可以了。