如何从下载的 tar.gz 文件安装 R Studio?

史蒂夫

我从 R Studio 网站下载了以下文件:

rstudio-1.2.1335-amd64-debian.tar.gz

到目前为止,我已经执行了以下操作:

sudo tar -zxvf rstudio-1.2.1335-amd64-debian.tar.gz 

请告知如何安装此类更新?因为我已经拥有以前的 R Studio。

马尔马约吉

RStudio 是 R 的免费开源集成开发环境,R 是一种用于统计计算和图形的编程语言。

RStudio 提供桌面(Windows、Mac 和 Linux)上的开源和商业版本,从 Web 浏览器到运行 RStudio Server 或 RStudio Server Pro 的 Linux 服务器。

如何使用 Tarball 在 Ubuntu 18.04 上安装 RStudio Desktop 1.2.1335(开源许可证)?

第 1 步 — 从 Rstudio 网站下载 tarball

rstudio-1.2.1335-amd64-debian.tar.gzRstudio 官方网站下载(147.8 MB 文件大小)到~/Download目录中。

第 2 步 — 将 tarball 解压缩到 /opt/rstudio

$ sudo mkdir -p /opt/rstudio
$ sudo tar xfvz ~/Downloads/rstudio-1.2.1335-amd64-debian.tar.gz --directory /opt/rstudio

第 3 步 - 创建符号链接 latest

$ cd /opt/rstudio/
$ sudo ln -s /opt/rstudio/rstudio-1.2.1335 latest

在此处输入图片说明 Figure-1: Setup symlink "latest" to point to rstudio-1.2.1335.

你为什么需要symlink latest

  • Symlink latest 始终跟踪 RStudio 安装的当前版本。
  • 明天,让我们说,新版本 1.3.1 到货,然后安装该版本。现在,您可以symlink latest通过发出以下命令删除指向旧版本 1.2.1335 的内容:

    $ sudo unlink /opt/rstudio/latest
    

    Symlink latest指向当前版本 rstudio-1.2.1335 但最新版本 1.3.1 的到来导致严重的symlink latestfrom 指向版本 1.2.1335。

  • 现在symlink latest使用以下命令创建指向较新版本 1.3.1:

     $ cd /opt/rstudio/
     $ sudo ln -s /opt/rstudio/rstudio-1.3.1 latest
    

    现在symlink latest指向较新的版本 rstudio-1.3.1。注意:没有1.3.1这样的版本,这只是fictional一个用来展示symlink latest.

  • 同时,您可能仍然保留旧版本而不删除它们。出于某些原因,您想在特定的旧版本上工作,您只需切换symlink latest指向该旧版本,就是这样!您无需更改任何其他设置。

  • 随后出现的第 4 步中,您将设置RHOMEPATH和环境LD_LIBRARY_PATH变量。由于此环境变量的值涉及symlink latest,因此即使您将来切换指向较新版本,这些设置也始终保持不变和原样!

步骤 4 — 创建 RStudio 环境变量PATH等。

要设置 RStudio 环境变量,请在/etc/profile.d目录中创建一个新文件

$ sudo touch /etc/profile.d/rstudio.sh
$ sudo vi /etc/profile.d/rstudio.sh

然后将以下行复制并粘贴到文件中:

#!/bin/bash
export RHOME=/opt/rstudio/latest
export PATH=/opt/rstudio/latest/bin:${PATH}
export LD_LIBRARY_PATH=/opt/rstudio/latest/lib:${LD_LIBRARY_PATH}

保存并关闭文件。使用以下命令使其可执行。

$ sudo chmod +x /etc/profile.d/rstudio.sh

然后,通过运行以下命令永久设置环境变量:

$ source /etc/profile.d/rstudio.sh

要验证PATH是否正确设置,请发出以下命令:

$ echo $PATH

在此处输入图片说明 Figure-2: PATH environment variable is set properly to "/opt/rstudio/latest/bin".

要验证LD_LIBRARY_PATH是否正确设置,请发出以下命令:

$ echo $LD_LIBRARY_PATH

在此处输入图片说明 Figure-3: LD_LIBRARY_PATH environment variable is set properly to "/opt/rstudio/latest/lib".

步骤 5 — RStudio 需要 R 3.0.1+

如果您还没有 R,请按照说明操作:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
$ sudo apt update
$ sudo apt install r-base

要知道 R 的版本,请发出以下命令:

$ R --version

在此处输入图片说明 Figure-4: R version is 3.6.0.

第 6 步 - RStudio IDE

您可以从命令行调用RStudio IDE,如下所示:

$ rstudio 

此命令将带您进入 RStudio 的集成开发环境。

在此处输入图片说明 Figure-5: Command "rstudio" takes you to RStudio IDE.

步骤 7:创建shortcut启动器桌面图标。

Create and install a new desktop file called rstudio.desktop which is a shortcut for RStudio.

$ cd ~
$ vi rstudio.desktop

Copy & Paste the following content into the file:

[Desktop Entry]
Name=RStudio
Type=Application
Exec=/opt/rstudio/latest/bin/rstudio
Terminal=false
Icon=/opt/rstudio/latest/rstudio.png
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;

Save and exit from the editor.

Now, run the following command to install shortcut file in /usr/share/applications/ directory:

$ sudo desktop-file-install rstudio.desktop

Now, you can click RStudio shortcut launcher icon from Dash to enter RStudio IDE.

在此处输入图片说明 Figure-6: "RStudio" shortcut launcher icon is shown in redbox on Dash desktop screen.

NOTE-1: With this, installation of RStudio Desktop v1.2.1335 (open source License) is complete.

This is where my Answer to the Post of Questioner SteveS ends. You may quit now.

NOTE-2: If you want to install RStudio Server v1.2.1335 (open source License), then you should go to next step-8, otherwise please quit now.

Step-8: How to install RStudio Server v1.2.1335 (Open Source License)?

RStudio Server enables you to provide a browser based interface to a version of R running on a remote Linux server, bringing the power and productivity of the RStudio IDE to server-based deployments of R.

To download RStudio Server, execute the following commands:

$ cd ~    
$ sudo apt-get install gdebi-core
$ wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.2.1335-amd64.deb

Note: You may choose to verify the build’s GPG signature prior to installing it.

Obtaining the Public Key

In order to validate a build’s signature, you must first import and trust RStudio’s public code-signing key. You can obtain the public key from a keyserver using gpg at the command line:

$ gpg --keyserver keys.gnupg.net --recv-keys 3F32EE77E331692F
gpg: key 3F32EE77E331692F: public key "RStudio, Inc. (code signing) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Validating Build Signatures

Issue the dpkg-sig command to validate the signature. Note: You may need to install the dpkg-sig package if it isn’t already installed.

$ dpkg-sig --verify rstudio-server-1.2.1335-amd64.deb
Processing rstudio-server-1.2.1335-amd64.deb...
GOODSIG _gpgbuilder FE8564CFF1AB93F1728645193F32EE77E331692F 1553752985

To install RStudio Server v1.2.1335, execute the following command:

$ sudo gdebi rstudio-server-1.2.1335-amd64.deb

Issue the following command to verify that RStudio Server is up and running:

$ sudo systemctl status rstudio-server.service

在此处输入图片说明 Figure-7: The status command displays "RStudio server 1.2.1335" is up and running.

By default RStudio Server runs on port 8787 and accepts connections from all remote clients. After installation you should therefore be able to navigate a web browser to the following address to access the server:

http://<server-ip>:8787

Since Server and client are in the same machine, you can use http://localhost:8787 to access RStudio server, as shown below:

在此处输入图片说明 Figure-8: Supply your usual Ubuntu system username and password to logon to RStudio Server through Web.

RStudio will prompt for a username and password, and will authenticate the user by checking the server's username and password database.

After authentication and logon to RStudio server is successful, you can access IDE through Web as shown below:

在此处输入图片说明 Figure-9: After successful logon to RStudio Server, IDE is accessible now through Web.

Next Steps

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章