Install APM Insight PHP Agent for Linux (PHP version below 7.0)
This installation process will only work on a Linux operating system. Refer here for Windows.
- Recommended method of installation
- Install using script
- Instructions for manual installation
- Instructions to install in docker
- Automatically restart agent during service reboots
Recommended method:
- Log in to your Site24x7 account > APM > Add PHP for Linux
- Copy and execute the given script in the terminal.
- Set preferred application name by changing the toggle button. By default, the name is set to PHP-application.
- Customize parameters as required and complete the installation.
- Restart your apache/fpm.nginx service to start monitoring.
- To view data, navigate to APM Insight > APM > Your application
Install using script
Use these instructions when you come across the following message while trying to install:
PHP is not found in PATH. Kindly install php or add php installation directory to PATH!
If PHP is managed by third-party applications, like cPanel/WHM, kindly refer to the manual installation steps below.
- Download the agent using the following command:
Verify the integrity of the downloaded agent using checksum validation. Learn more.
wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zip
- Move the agent to /opt/ directory and extract the contents of the downloaded file. This will create a directory zpa/ under /opt/.
sudo unzip -d /opt/ agent_php.zip
- Navigate to zpa/bin directory and execute the following command:
Note:
cd /opt/zpa/bin sudo sh configure.sh
- licensekey is mandatory. Provide your Site24x7 license key in the code in the line above.
- applicationname is the monitor name to be shown in Site24x7 console. It is optional, and by default, is set to PHP-Application.
- Restart your web servers. If you are running Apache, restart apache/httpd service. If you're running nginx/fpm based servers, restart the php-fpm services.
- For Apache2 (Debian)
sudo service apache2 restart
- For Apache2 (RHEL/CentOS)
sudo service httpd restart
- For nginx/fpm based servers.
sudo service php-fpm restart
- For Apache2 (Debian)
- Once the agent is installed successfully, you can view the monitor in the Site24x7 Console under APM -> APM Insight -> Applications.
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:
If PHP is installed using third-party managed services, like cPanel/WHM, or if the PHP path is not set properly during the installation, you might get the following message:
PHP is not found in PATH. Kindly install php or add php installation directory to PATH!
In these cases, you can retry the installation after setting the correct PHP directory in the PATH variable, or you can proceed to configure the agent manually, using these steps.
- Download the agent using the following command:
Verify the integrity of the downloaded agent using checksum validation. Learn more.
wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zip
- Move the agent to /opt/ directory and extract the contents of the downloaded file. This will create a directory zpa/ under /opt/.
sudo unzip -d /opt/ agent_php.zip
- Find your PHP API version, using the following command. There should be a corresponding zpa.so file in the /opt/zpa/libdirectory for the respective API version. Eg., zpa20131226.so for API version 20131226.
php -i | grep "PHP API"
# Example output
PHP API => 20131226 - Find your PHP's ini configuration path. This is the path where dynamically loaded extension configurations are added. Copy the /opt/zpa/bin/zpa.inito this location.
php -i | grep "Scan this dir"
# Example output
# Scan this dir for additional .ini files => /opt/cpanel/ea-php56/root/etc/php.d/
cp /opt/zpa/bin/zpa.ini /opt/cpanel/ea-php56/root/etc/php.d/zpa.ini - Note: Use this step, only when the output in step 4 in this section is not configured. In case the ini configuration path is not set, the extensions must be configured in the php.ini file directly. Add the following line to php.ini near the end of the file.
extension=zpa.so
- Find your PHP's extension directory. This is the path where extension libraries are loaded. Copy the respective zpa.so file for the API version obtained from step 3 in this section.
php -i | grep "extension_dir"
# Example output
# extension_dir => /opt/cpanel/ea-php56/root/usr/lib64/php/modules
cp /usr/lib/php/zpa20131226.so /opt/cpanel/ea-php56/root/usr/lib64/php/modules/zpa.so - Restart your web servers. If you are running Apache, restart apache/httpd service. If you're running nginx/fpm based servers, restart the php-fpm services.
# For Apache2 (Debian) sudo service apache2 restart
# For Apache2 (RHEL/CentOS) sudo service httpd restart
# For nginx/fpm based servers. sudo service php-fpm restart - Verify if the agent is successfully loaded using the following command. The output should contain zpa.
php -i | grep zpa
#Example output
#zpa
#zpa.version => 3.0.2
#zpa.date => 7 May 2021
#zpa.capture_clirequest => 1 => 1
#zpa.capture_httphost => 0 => 0
#zpa.capture_phpself => 0 => 0 - To start communicating with Site24x7, add the Site24x7 license key to /opt/zpa/conf/apminsight.conf. Place the license key value in the line beginning with license.key=<Enter_license_key_here>
################### APM Insight Agent Configuration File ###################
#
license.key=<Enter_license_key_here>
# - Navigate to /opt/zpa/binand start the agent service, by executing the following command:
To make sure the agent is restarted during system reboots, you can register the agent as a service. Alternatively, you can use rc.local or cron task to ensure agent is started during system reboots.
cd /opt/zpa/bin
sudo sh run.sh start
# To verify the status
# ps -ef | grep zpdp
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
Related article
Troubleshooting steps if you don't see any data after installing the PHP agent