Install the Ruby agent

Install the Ruby agent on your system.


Create account

Installing the Sqreen Ruby agent allows you to monitor the security of your application and block attacks in real-time. Installing Ruby in your Rails application takes less than a minute:

Standard Ruby application

In your application root directory, add the Sqreen gem to your Gemfile:

echo "gem 'sqreen', '>= 1.16'" >> Gemfile

{!partials/org-token.md!}

Then, in a terminal, use the following commands from your application root directory:

# Install the Sqreen gem from your application directory
bundle install

# Set the Sqreen token and the application name
cat > config/sqreen.yml <<EOF
app_name: "YOUR_APPLICATION_NAME"
token: "SQREEN_TOKEN"
EOF

{!partials/app-token-depreciation.md!}

Install the agent on non production environments

{!partials/install-agent-multiple-envs.md!}

# Set the Sqreen token and the app name, including the environment
cat > config/sqreen.yml <<EOF
app_name: "foobar (production)"
token: "SQREEN_TOKEN"
EOF

Basic configuration

The Sqreen agent stores your configuration in the sqreen.yml file.

{!partials/install-agent-env-vars.md!}

export SQREEN_APP_NAME="YOUR_APPLICATION_NAME"
export SQREEN_TOKEN="SQREEN_TOKEN"

The Sqreen Ruby agent provides flexible configuration settings. Refer to Configuration of the Ruby agent for more detailed information.

Uninstall the agent

To uninstall the Sqreen agent, remove the sqreen gem from your Gemfile.

Notes

The Sqreen Ruby agent's gem is available in the rubygems repository.

Use different Sqreen applications for different environments

We recommend you to use different Sqreen applications on your different environments: production, staging and development.

Bundler app (Sinatra)

For bundler apps (Sinatra), use the standard installation instructions for the Ruby agent and require the Sqreen gem from your application code after Sinatra in the Gemfile:

require 'sinatra'
require 'sqreen'

Linux distributions with no C++11 compiler

Some specific environments lack a C++11 compliant compiler (GCC >= 4.8 or clang >= 3.5). For example:

  • Stripped down Docker containers
  • Old distributions, such as Ubuntu Precise

In the first case, install g++ or clang before running bundle install or gem install. You can remove the C++ compiler afterwards, but you must keep the C++ runtime library (usually libstdc++).

In the case of older distributions, you might need to install a newer compiler from separate package repositories.

Travis Precise

To install Sqreen on Travis Precise, you can install GCC 4.8 by adding the following to the .travis.yml file:

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8
env:
  - CXX=g++-4.8