Installation of the PHP agent (Debian/Ubuntu)


TL;DR

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

  • Sign up to Sqreen to create your account
  • Pick up your first application name and language. The name of the application can be the name of the repository, or anything that will help you identify the app in your Sqreen dashboard
  • Follow the procedure detailed below

This procedure will install both parts of the agent: the language extension and the daemon. Both parts are necessary for the agent's operation. Read more about the structure of the PHP agent.

Standard PHP Application

From a terminal, add our custom repository containing the Sqreen agent packages using our custom script:

curl -s https://8dc0b36f0ea6f2f21b721765e10a7e02768cd1825b4551f4:@packagecloud.io/install/repositories/sqreen/sqreen/script.deb.sh | bash

Then install the Sqreen PHP extension and the Sqreen daemon:

apt-get install sqreen-agent sqreen-php-extension

Finally, add your Sqreen token in the agent's configuration (your Sqreen token is available on the application dashboard you set up in the previous step).

/usr/lib/sqreen/sqreen-installer config YOUR_TOKEN_HERE

Don't forget to restart your HTTP server.

Install the agent outside production environment

Typically you will install the Sqreen PHP agent in your production environment, but you can create several applications using your Sqreen dashboard, and specifying the environment (development, staging, production). A unique Sqreen token will be provided for each of your applications.

Basic configuration

After installing the agent, your configuration will be stored in the configuration file sqreen.ini. At the moment this file contains only your Sqreen token.

The Sqreen PHP agent provides flexible configuration settings. Refer to Advanced Configuration in PHP for more detailed information.

All done! 🙌

At this point, the PHP is ready to use! No further configuration or installation is necessary in most cases. However, if you need to e.g. use the daemon on another machine, then please read on to the next section.

Disable the agent

You can disable the agent anytime by visiting your Sqreen Dashboard, go to the Settings section and switch off the Sqreen status.

Uninstall the agent

To uninstall the Sqreen agent, simply remove the packages:

apt-get remove sqreen-agent sqreen-php-extension

Custom Repository setup

If you require more control or configuration over how these two components are installed, this section will help you understand in more detail how each component can be installed and configured separately.

The Sqreen PHP agent is available on a hosted repository. Use the following steps to manually install the Sqreen repository in your application.

sudo apt-get update
sudo apt-get install debian-archive-keyring

Install a package called apt-transport-https to make it possible for apt to fetch packages over https.

sudo apt-get install -y apt-transport-https

Next, use this command to create a read token and output the necessary repository configuration. Replace os and dist with a the Linux distribution and version strings for your system (ubuntu or debian, and a version string like precise or trusty). Replace UNIQUE_ID with a unique identifier of your choice for your system:

UNIQUE_ID=`hostname -f` && curl 'https://8dc0b36f0ea6f2f21b721765e10a7e02768cd1825b4551f4:@packagecloud.io/install/repositories/sqreen/sqreen/config_file.list?os=ubuntu&dist=precise&name=${UNIQUE_ID}' > /etc/apt/sources.list.d/sqreen_sqreen.list

Then update the package cache:

sudo apt-get update

You can now install the daemon sqreen-agent as well as the sqreen-php-extension:

sudo apt-get install sqreen-agent sqreen-php-extension