Installing APM Insight PHP Agent in Linux


To install APM Insight PHP agent in Linux operating system, follow the below given instructions:

Instructions for installation using script

  1. In Applications Manager web client, go to APM Insight tab and copy the License Key present in the helpcard.
  2. Download the APM Insight PHP Agent agent Linux file (agent_php.zip) from the download page to the required Linux server.
  3. Start by logging into root.
  4. Extract the agent_php.zip file into /opt directory. This will create a sub-directory called zpa.

    $ cd /opt
    $ wget [agent_php.zip LINK]
    $ unzip agent_php.zip

  5. Navigate to zpa/bin directory and execute the command:

    $ cd zpa/bin
    $ sudo sh configure.sh [ENTER LICENSE KEY HERE]

  6. Open the apminsight.conf file available in the zpa/conf directory and include the following keys:

    For PHP agent versions below 2.9.3:

    apm.host=[HOST-NAME]
    apm.port=[HOST-PORT]
    use.https=[true/false]

    For PHP agent versions 2.9.3 and above:

    apm.host=[HOST-NAME]
    apm.port=[HOST-PORT]
    apm.protocol.https=[true/false]

    Example:

    For PHP agent versions below 2.9.3:

    apm.host=localhost
    apm.port=8443
    use.https=true

    For PHP agent versions 2.9.3 and above:

    apm.host=localhost
    apm.port=8443
    apm.protocol.https=true

    After including the required keys, save and close the file.

  7. Restart your PHP agent using the following command:

    $ sh run.sh restart

  8. Restart your web server / FPM server using the following commands:

    #For Apache servers,
    $ sudo service apache2 restart

    #For FPM servers,
    $ sudo service php-fpm restart

How to verify if the installation is successful:

After the installation, go to the terminal and execute the following command:

$ php -m | grep zpa

The output should contain zpa.

Note:

The agent does not restart automatically during server reboots. To start, stop or restart the agent, use the following commands:

$ cd /opt/zpa/bin

#Start the agent
$ sh run.sh start

#Stop the agent
$ sh run.sh stop

#Restart the agent
$ sh run.sh restart

#For systemd supported OS, use the following command to restart:
$ service zpdpsvc restart

Automatically restart agent during service reboots

To automatically restart APM Insight PHP agent during system reboots, use the below given steps:

For systemd servers:

The agent will automatically start during server reboots for systemd supported Linux flavors.

For non systemd servers:

  1. Edit the /etc/rc.local file
  2. Add the following lines to the rc.local:

    cd /opt/zpa/bin
    sh run.sh restart

    and save that file