Skip to main content

PHP installation and configuration in a container

Use this workflow with the Add New PHP agent wizard to ensure you have all the steps covered for installing and configuring the PHP agent in a container. Using the wizard is the simplest way to deploy a new agent.

Before you begin

Make sure you have everything you need before you start.

  • The agent will need to be able to reach your Contrast instance. It can be a local/on-premise instance or a hosted instance. A proxy can be configured if the environment has limited network access.

  • It must use supported versions, frameworks, and tools.

  • Understand the order of precedence

  • You will also need access to a command line interface (with a chosen directory for downloading the agent) and your organization's instance of Contrast

Start the PHP agent wizard

  1. Open the agent wizard:

    • Northstar: From the left navigation, select Administration > Agent management. Then, select Add agent at the top of the view.

    • Contrast: Use either of these options:

      • From the header, select Add New and then, select the Application card.

      • Select Administration > Agent management. Then, select Add agent at the top of the view.

  2. Select Language-specific.

  3. Under Select a language, select PHP.

Select method to deploy with containers

  1. Under Select application deployment method, select Install with a container.

  2. Under Select method to deploy with containers, select Dockerfile or Kubernetes.

Dockerfile

Build image with the agent:

  1. Under Build image with agent, copy and run the command block displayed in the wizard and add it to your Dockerfile.

  2. Copy and run the second command to build the image.

Configure the agent:

Under Configure the agent, select a configuration option. The agent requires a connection token or an API configuration to communicate with Contrast. You can use a connection token (recommended) or you can download the configuration as a YAML file.

Register the application (Optional):

When you register an application, you can assign it to groups for access control and assign tags and metadata to the application by entering the application name, tags, and metadata, and selecting Register application.

Use Connection Token (Recommended):

This configuration method uses a single variable to specify authentication values. Copy the code displayed in the wizard and set the variable in a location where the agent has access to it.

If you prefer to configure the agent using a YAML file, you can download contrast_security.yaml from the configuration editor, and place the file in a supported YAML file location instead. Raise your permissions to write the configuration file to /etc/contrast, and then copy the code displayed in the wizard.

Note

The environment variables need to be set before the agent starts up, and in a location where the agent has access to it. Environment variables can be set within the same process or system-wide.

Kubernetes (Linux only)

  1. Under Select method to configure agent operator, select Helm charts (recommended) or Manifest.

  2. For Helm:

    1. Under Download and set up the values file, copy the code displayed in the wizard to create a values file. Skip this step if you already have the operator installed.

    2. Under Install and deploy Helm chart, run the Helm commands in the wizard. Skip this step if you already have the operator installed.

    3. Under Label namespaces, run the command displayed to label your namespaces to add AgentInjectors.

    4. Under Label deployments, follow the wizard steps and run the commands to label your deployments.

  3. For Manifest:

    1. Under Install operator, run the commands displayed in the wizard to install the Contrast agent operator. Skip this step if you already have the operator installed.

    2. Under Configure operator, follow the wizard steps to  Deploy secrets in namespace, Connect agents in cluster and maps, apply the configuration file. Skip this step if you already have the operator installed.

    3. Under Configure Injector, copy or download the YAML file, run the kubeclt apply command displayed in the wizard, and then wait for the command to complete.

    4. Under Label namespaces, run the command displayed to label your namespaces to add AgentInjectors.

    5. Under Label deployments, follow the wizard steps and run the commands to label your deployments.

Configure agent (optional):

Copy the code to set agent settings once for every injected workload in the namespaces selected. The operator turns the yaml block into environment variables on the pod.

Verify the agent deployment

  1. Interact with your application as you normally would. For example, interact with your application's web interface or send API commands.

  2. Select Administration, then Agent management to verify that your agent appears in the list.

  3. Verify that you see the name of your application in the list.