This is an extended and code-rewritten version of:
https://github.com/leondutoit/shiny-server-on-ubuntu
Thanks to Joe Cheng, Yihui Xie, and Jeff Allen for resolving problem with language locales and upstart delays on virtual machines; and all the other RStudio/Shiny stuff, evidently.
The Shiny server (http://shiny.rstudio.com) and the RStudio IDE server (http://rstudio.com) only run in Linux systems. If you are working in Windows, you have to connect to an external Linux server, or configure a virtual system. With vagrant (http://www.vagrantup.com/), the installation and configuration of a virtual system can be automated; all required files are downloaded from the Internet using the Puppet (http://puppetlabs.com/) configuration system.
A vagrant-package does not contain the virtual machine and the installation, but rather the rules to construct one. Therefore, it is a small download, about 15kB zipped.
All features described here have only been tested with Windows as the host operating system.
No attempts have been made to create a secure installation; passwords are well-known (vagrant/vagrant
and shiny/shiny
).
All commands starting with vagrant should be given on the command line (i.e. the black box in Windows). If the command vagrant
fails, please add the path to the directory with vagrant.exe
to the PATH environment variable.
This installation has been tested with Oracle VirtualBox, version 4.3.8, 4.3.12 and 4.3.20 on a Windows 7/64 host; and Vagrant 1.5.4. There is a major issue with synchronized folders in Virtual Box 4.3.10; see here and here; do not use this version.
- Install Oracle Virtual Box. Do not use version 4.3.10! Last version successfully tested is 4.3.20.
- Install Vagrant; best install it into folder
D:\vagrant
orC:\vagrant
to avoid theHashiCorp
-super-folder. - Create a subfolder of
\vagrant
; we assumed it is called\vagrant\rstudio-shiny-server-on-ubuntu
, but you can choose any name you like. - When you have
git
installed, clone the project into this subfolder:git clone [email protected]:dmenne/rstudio-shiny-server-on-ubuntu.git
. - When you do not have
git
installed, download the zip file and unzip it into the\vagrant\rstudio-shiny-server-on-ubuntu
directory. Note that the zip file may be a few revisions behind the git version. - Open a Command Window in the repository folder, e.g
cd \vagrant\rstudio-shiny-server-on-ubuntu
; this is the folder that contains a file namedVagrantfile
. - Run:
vagrant up
from the command line in this directory; this will need some time on the first start, because all packages are downloaded. With a good Internet connection, the first installation will need about 40 minutes, or 20 minutes when the Ubuntu box has been cached. - If there are no errors, continue running Shiny or RStudio. If there are errors, read below "Troubleshooting and additional info"
- In your browser, use
localhost:3838
to connect to the Shiny servers. To edit your Shiny project, use the mapped folder invagrant\rstudio-shiny-server-on-ubuntu\shiny-server
; you do not have to do any work in the Ubuntu-box. - You can connect to Shiny in your network, if the port 3838 is open. See the RStudio server installation instructions how to change the port.
- On each system start, a script checks if there are new user-installed Shiny applications in the
vagrant/R
path, and creates links to these displayed in the index page when Shiny is started. When you install a new application with Shiny apps, these are only visible in the index after avagrant reload
. The script tries to find a useful name, avoiding the ubiquitousshiny
for display in the index page.
- In your browser, use
localhost:8787
to connect to RStudio. The user name isshiny
and the password is alsoshiny
. Your home directory map tovagrant\rstudio-shiny-server-on-ubuntu\shiny-server
in the host operating system (assumed Windows).
- The OpenCPU server is installed and redirected to port 8080 on the host. Try localhost:8080/ocpu. For details, see https://www.opencpu.org/ .
- Use RStudio to install packages from the CRAN server; see the RStudio documentation for details.
- To install from a local source package (
xxx.tar.gz
), copy the file tovagrant\rstudio-shiny-server-on-ubuntu\shiny-server
, and use the package installation (Packages/Install/Install from: Package archive). - If the installed package has a Shiny app, after a
vagrant reload
the app will be listed on the home page of Shiny; see filemakeshinylinks.sh
how this magic happens on system reboot. You only have to do the reload once after installation of a new packages, not after installing updates.
- If you see error messages, try again:
vagrant reload
and/orvagrant provision
. - When in doubt run:
vagrant destroy
followed byvagrant up
. - To connect to the Ubuntu system, use
vagrant ssh
; no password required. This is an insecure connection, and intended to be used on a local machine only. You must have SSH installed on your computer, e.g. from git or MinGW. - To re-run the installation of the R-related components, use
vagrant provision
- For more detailed debugging information, uncomment the line
#:options => ["--verbose", "--debug"] do |puppet|
in fileVagrantfile
by removing the#
and prepending a# to
:options => [] do |puppet|``. - The important information controlling the installation is in file
Vagrantfile
,usefulpackages.R
, andpuppet/manifests/rstudio-shiny-server.pp
. - If you want to map additional directories to your Windows host, add lines following the pattern
config.vm.synced_folder "etc", "/etc/shiny-server", create:true
toVagrantfile
, and do avagrant reload
. - If you want additional R-packages installed, add these to the list in
usefulpackages.R
; do not forget to make a copy of the changes, this file will be overridden when you update to a more recent version ofrstudio-shiny-server-on-ubuntu
. - Check the top lines in
puppet/manifests/rstudio-shiny-server.pp
if you want to change the installed server versions; details are given here: for RStudio and for Shiny - The default installation gives 2048MB memory to the VM. This might be too much, forcing smaller host systems to a crawl, so check the line
v.memory = 2048
inVagrantfile
- It is not necessary to keept the "black box" open to run the server. The system can run totally in the background.
- Once everything works ok, you can start and stop the Virtual Box system in your Oracle VM Virtual Box manager; use
rstudio-shiny-server-on-ubuntu_default
. Only usevagrant reload
when you have changed settings. - When you have in installed the optional snapshot plugin (see above), you can take a snapshot with
vagrant snapshot take <name>
,vagrant snapshot list
to list them, andvagrant snapshot go <name>
to restore a snapshot.