Help APM APM for PHP Install PHP Agent for Linux

Install PHP Agent for Linux

Install APM Insight PHP Agent

This installation process will only work on a Linux operating system. Refer here for Windows.  
  1. Instructions for installation using script
  2. Instructions for manual installation
  3. Instructions to install in docker
  4. Automatically restart agent during service reboots

Install using script

Start by logging into root

  1. Extract the agent_php.zip into /opt directory. This will create a sub-directory called zpa.
    $ cd /opt
    $ wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zip
    $ unzip agent_php.zip 
    Verify the integrity of the downloaded agent using checksum validation. Learn more.
  2. Navigate to zpa/bin directory and execute the command   
    $ cd zpa/bin
    $ sudo sh configure.sh <ENTER LICENSE KEY HERE> <Desired_Application_Name>  
  3. Restart your web server / FPM server
    #If you're running apache,
    $ sudo service apache2 restart
    #For FPM servers
    $ sudo service php-fpm restart

How to verify if the installation is successful:

After installation, go to 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


Manual installation:

  1. Download the agent_php.zip from your Site24x7 login. Alternatively, you can wget it using
    wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zip
  2. Copy the agent_php.zip to /opt directory and unzip the agent.
    cp agent_php.zip /opt/
    cd /opt
    unzip agent_php.zip
  3. For manual installation, figure out which version of php is currently configured using the below command. You should see an output like APIxxxxx,NTS. 
    php -i | grep API
    Sample Output:
    Server API => Command Line Interface PHP API => 20090626  Zend Extension Build => API220090626,NTS PHP Extension Build => API20090626,NTS 
  4. Navigate to the /opt/zpa/lib directory and copy the corresponding zpaXXXX.so file to /usr/lib/php/ directory. 
    cd /opt/zpa/lib
    sudo cp zpa20090626.so /usr/lib/php/20090626/zpa.so 
  5. Verify if the php installation supports configuring extensions from ini files.
    php -i | grep Scan
      Sample Output:
    Scan this dir for additional .ini files => /etc/php/5.3/cli/conf.d
  6. If your php version has this setting, copy the zpa.ini file in /opt/zpa/bin directory to the additional ini directory. Note that conf.d is a symbolic link directory. The actual symbols will usually be in /etc/php/xxx/mods-available/.

    cd /opt/zpa/bin
    sudo cp zpa.ini /etc/php/5.3/mods-available/zpa.ini
    In some custom built php versions without --with-config-file-scan-dir flag, this setting will be displayed as below
    Scan this dir for additional .ini files => Not configured
    In such cases, the only way to make an extension work is to edit the php.ini file manually, and add the following line at the end of the file 
    extension=zpa.so 
    After all these modifications, restart the apache/nginx server and 
    service apache2 restart
  7. Verify if zpa module is loaded in the server 
    php -m | grep zpa
    Sample output:
    zpa
  8. Edit /opt/zpa/conf/apminsight.conf and enter your license key by editing the following configuration.
    license.key=<ENTER LICENSE KEY> 
    (Optional) Change your application name by modifying the following configuration
    application.name=PHP-Application
  9. In manual installation, start the zpdp process by running the following command. 
    cd /opt/zpa/bin
    sudo sh run.sh start
  10. Check whether the zpdp process is started. 
    ps -ef | grep zpdp
    Sample output:
    root 314 1 0 00:00 ? 00:00:01 ./zpdp -loglevel WARNING 
  11. Generate some traffic on the web server if this is a testing setup. The data should be populated within a couple of minutes in site24x7 console. 

Install in docker:

While creating container images, add these commands to the dockerfiles used for image creation as follows:

RUN cd /opt/ && wget
https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zip
RUN unzip agent_php.zip
RUN cd /opt/zpa/bin && sh configure.sh<licensekey><app_name>
RUN sh run.sh start

Whenever the container is started, make sure zpdpsvc is restarted using the following command (under /opt/zpa/bin directory)

sh run.sh start

 

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help APM APM for PHP Install PHP Agent for Linux