-
Notifications
You must be signed in to change notification settings - Fork 288
Building Shiny Server from Source
RStudio provides some pre-compiled installers for Shiny Server (currently x86-64 only). If you're using a supported version of Ubuntu, RedHat, or SLES, we recommend that you use one of these pre-built installers. If you're on a different distribution or prefer to build from source, these instructions may help.
The following software must be available on the system before continuing:
- Python 3.6+
- If Python 3.12+,
distutils
must be installed as well. This may be available via distro package manager (e.g. Ubuntu haspython3-setuptools
), or else you can install usingpip install setuptools
.
- If Python 3.12+,
cmake
-
gcc
(gcc 4.8 or newer is required) -
g++
(g++ 4.8 or newer is required) git
-
R-base-devel
- Many distributions provide two packages when distributing R: one for base R and one "devel" package which is helpful in building extra packages, among other things. In addition to base R, Shiny Server requires many of the components typically included in the "devel" packages, such aslibpng
andlibjpg
. If you're on a platform that doesn't have such a "devel" package, be sure to include these components when installing R.
Finally, you must install the Shiny package in the system-wide library. One way to do that is the following command:
sudo su - -c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
Note that you may need to download the package and install it from the command line if you're using an older version of R that doesn't support installation from an HTTPS CRAN repo, or use un-encrypted HTTP (insecure).
Once all of the prerequisites have been satisfied, you can use the following commands to download and install Shiny Server.
# Clone the repository from GitHub
git clone https://github.com/rstudio/shiny-server.git
# Get into a temporary directory in which we'll build the project
cd shiny-server
mkdir tmp
cd tmp
# Install our private copy of Node.js
../external/node/install-node.sh
# Add the bin directory to the path so we can reference node
DIR=`pwd`
PATH=$DIR/../bin:$PATH
# Use cmake to prepare the make step. Modify the "--DCMAKE_INSTALL_PREFIX"
# if you wish the install the software at a different location.
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
# Get an error here? Check the "How do I set the cmake Python version?" question below
# Compile native code and install npm dependencies
make
mkdir ../build
(cd .. && ./bin/npm ci --omit-dev)
# Install the software at the predefined location
sudo make install
# Install default config file
sudo mkdir -p /etc/shiny-server
sudo cp ../config/default.config /etc/shiny-server/shiny-server.conf
At this point, you've successfully installed Shiny Server! You'll still need to configure a few directories and other assets in order for Shiny Server to work properly, however. We'll do this in the next section.
Shiny Server will look for resources in specific locations. Some of these (log directories, application directories, etc.) can be modified using a configuration file stored at /etc/shiny-server/shiny-server.conf
. If no such file is provided, the default configuration will be used. The following commands prepare a system for such a configuration.
# Place a shortcut to the shiny-server executable in /usr/bin
sudo ln -s /usr/local/shiny-server/bin/shiny-server /usr/bin/shiny-server
# Create shiny user. On some systems, you may need to specify the full path to 'useradd'
sudo useradd -r -m shiny
# Create log, config, and application directories
sudo mkdir -p /var/log/shiny-server
sudo mkdir -p /srv/shiny-server
sudo mkdir -p /var/lib/shiny-server
sudo chown shiny /var/log/shiny-server
sudo mkdir -p /etc/shiny-server
At this point, you should be able to follow the Configuration section of the README to begin serving some Shiny applications. You should be able to start the server from the command line by executing shiny-server
(either as the shiny
user, or as root). If you'd like Shiny Server to start automatically when your machine is booted, see the associated question in the F.A.Q. below.
For systems that run systemd or upstart, you can find sample scripts in the subdirectories of this: https://github.com/rstudio/shiny-server/tree/master/config
See your operating system's documentation for instructions on installing and enabling systemd/upstart scripts.
If your distribution does not use systemd or upstart, you'll likely need to create an init.d
script for Shiny Server. We provide some init.d
scripts here that may serve as a useful guide for you, but they may need some modification to work as expected on your distribution. Unfortunately, because the init.d
files vary from distribution to distribution, we aren't able to provide exhaustive documentation on how to make this work on your particular setup. Once properly configured, you can run sudo /etc/init.d/shiny-server start
to manually start Shiny Server.