Install PHP Agent for Linux
Install APM Insight PHP Agent
- Recommended method of installation
- Install using script
- Instructions for manual installation
- Instructions to install in docker
- Automatically restart agent during service reboots
- 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
Use these instructions when you come across the following message while trying to install:
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:
wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zipVerify the integrity of the downloaded agent using checksum validation. Learn more.
- 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:
cd /opt/zpa/bin sudo sh configure.shNote:
- 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:
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:
#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
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:
wget https://staticdownloads.site24x7.com/apminsight/agents/agent_php.zipVerify the integrity of the downloaded agent using checksum validation. Learn more.
- 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:
cd /opt/zpa/binTo 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.
sudo sh run.sh start
# To verify the status
# ps -ef | grep zpdp
While creating container images, add these commands to the dockerfiles used for image creation as follows:
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)