Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
compat many fixes Jul 18, 2013
control build opencpu 2.1 with R 3.5 Nov 20, 2018
opencpu-server.postinst minor tweaks Mar 7, 2019

Building OpenCPU on Debian/Ubuntu

How to build OpenCPU on Debian or Ubuntu

Update R (optional, but recommended)

Because r-base packages included with Debian/Ubuntu are often old, we first add a repository with a recent version of R. On Ubuntu we can use Michael Rutter's launchpad repository:

sudo add-apt-repository -y ppa:marutter/rrutter
sudo apt-get update

Alternatively, on Debian use r-base packages from CRAN (see details). For example on Debian 8.0 ("jessie")

# Become root
sudo -i

# Add Wheezy CRAN repo for R 3.0+
apt-key adv --keyserver --recv-key 381BA480
echo "deb jessie-cran3/" > /etc/apt/sources.list.d/cran.list
apt-get update

# Quit root

Install Build Dependencies

First install dependencies required for building OpenCPU:

# Update system
sudo apt-get update
sudo apt-get dist-upgrade -y

# Install build dependencies
sudo apt-get install -y wget make devscripts r-base r-base-dev libapparmor-dev libcurl4-openssl-dev libprotobuf-dev protobuf-compiler xvfb xauth xfonts-base curl libssl-dev libxml2-dev libicu-dev pkg-config libssh2-1-dev

Building OpenCPU

To build OpenCPU Server (opencpu-server and opencpu-cache): run this not as root.

cd ~
tar xzf v2.1.tar.gz
cd opencpu-server-2.1
dpkg-buildpackage -us -uc

Installing OpenCPU server

To install the cloud server, simply install the deb packages in the following order:

cd ~

# Only if needed, see above
sudo dpkg -i libapache2-mod-r-base_*.deb

# Always needed
sudo dpkg -i opencpu-lib_*.deb
sudo dpkg -i opencpu-server_*.deb

You're done! Test if it works:

curl http://localhost/ocpu/info

That should print some info about the R session.

Extra: enable AppArmor (debian only)

OpenCPU uses AppArmor to enforce advanced security policies. AppArmor support is installed by default on Ubuntu, but in Debian we first need to enable it in the kernel. To do so, edit /etc/default/grub and add security=apparmor to the GRUB_CMDLINE_LINUX line. For example it would read:


Update the grub config and reboot:

sudo update-grub
sudo reboot

After rebooting, install the apparmor packages and verify that it is enabled:

sudo apt-get install apparmor-utils
sudo aa-status

Restart OpenCPU and check the log files to confirm that apparmor works:

sudo service apache2 restart
sudo tail /var/log/apache2/error.log -n30

OpenCPU caching server (not recommended)

The opencpu-cache package is a reverse proxy for caching and load balancing with OpenCPU. When installed, it automatically preroutes all incomming traffic on ports 80 and 443 through nginx. Only install this when you expect serious traffic.

# Dependencies
sudo apt-get install nginx

# Package builds
cd ~
sudo dpkg -i opencpu-cache_*.deb

Note that it is possible to install opencpu-cache on another server than opencpu-server if you update the nginx back-end config accordingly.

You can’t perform that action at this time.