ls - show the current diretory pwd - show the current folder cd - go to folder nano - edit file cat - show the content of a file mv - move a folder to another location
系统升级
apt-get
是Ubuntu操作系统下面的软件管理工具,需要升级才可以下载安装最新版本的工具包。
sudo apt-get update
安装R和Shiny相关
sudo apt-get install r-base
sudo apt-get install r-base-dev
sudo apt-get install gdebi-core
sudo apt-get install git
# wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.14.948-amd64.deb
# sudo gdebi shiny-server-1.5.14.948-amd64.deb
这里的v1.5.14
是目前shiny-server最新版本。
Open this file ~/.Rprofile
and type in the following:
options(download.file.method = "libcurl")
local({
r <- getOption("repos")
r["CRAN"] <- "https://cran.rstudio.com/"
options(repos=r)
})
control + X
: to exit editing file
shift + Y
: to confirm saving the file
cat ~/.Rprofile
: to double check
方法一
sudo su - -c "R -e \"install.packages('shiny')\""
方法二
$ sudo R
> install.packages('shiny')
这一步会将shiny安装到这个目录下/opt/shiny-server/
。
当shiny服务器安装好之后,输入下面命令来运行服务器。
sudo systemctl start shiny-server
如果发生故障,可以尝试重启:
sudo systemctl restart shiny-server
管理 > 本实例安全组 > 安全组列表 > 手动添加 > 目的3838 > 对象 0.0.0.0/0
.
这里要打开3838端口是因为这个是Shiny服务器实用的默认端口。选择IP地址(对象)0.0.0.0的意思是允许任何IP地址访问。有些时候有些网站希望只能对个别IP地址访问,也可以填写具体的IP地址。
在这个时候,只需要输入云计算机的公网IP地址,加上3838端口,就可以访问默认的shiny网页了。比如说,
http://47.252.19.149:3838
(备注:这个是我之前租的北美的服务器,目前已经到期,链接不可用。)
最后,只需要将代码放入到该目录即可cd /srv/shiny-server
。
比如说,将代码放在/srv/shiny-server/ESIShiny
目录下,我们将可以通过公网IP,加上端口,加上子目录,访问网页。
http://47.252.19.149:3838/ESIShiny
(备注:这个是我之前租的北美的服务器,目前已经到期,链接不可用。)
安装额外工具包
当然,如果网页用到其它的工具包,也需要都安装上。比如说,ESIShiny需要这些:
install.packages('ggplot2')
install.packages('wordcloud')
install.packages('stringr')
install.packages('plyr')
install.packages('tidytext')
install.packages('memoise')
install.packages('reshape2')
install.packages('DT')
代码拷贝到云计算机
那么,怎么把代码拷贝到云计算机上呢?有多种方法可以将代码拷贝到服务器上。帅帅常常用的是一个叫scp
的命令,可以参考:
另外,现在常用git代码管理系统。目前最流行的是GitHub,推荐:
brew install git
URL is copied from github.
git clone https://github.com/yzhong52/ESIShiny2.git
$ git add .
$ git commit -m "Add all code"
# git push
git clone https://github.com/yzhong52/ESIShiny2.git
https://rstudio.com/products/shiny/download-server/ubuntu/ https://docs.rstudio.com/shiny-server/#ubuntu-14.04