When the PHP agent starts, it automatically starts the Java proxy that handles communication between the PHP agents and the controller. 

Automatic startup of the proxy works for the great majority of situations. However, you can suppress the automatic startup of this script and run it manually. You would do this if:

  • You plan to instrument a PHP CLI entry point. The PHP CLI entry point requires manual startup of the proxy and immediate creation of the node on startup.
  • You have multiple Apache or FPM pools on the same machine reporting to the same proxy.

To do this, you first need to configure the agent for manual proxy launch. Then you need to launch the proxy manually. 

Configure the Agent for Manual Proxy Launch

The PHP Agent configuration needs to be modified to reflect manual launching.

To configure the agent for manual launching:

  1. Open the PHP configuration file for editing. The file is php.ini or appdynamics_agent.ini, depending on your setup.
  2. Set the agent.auto_launch_proxy setting to 0.
  3. Set the agent.proxy_script to the path of the runproxy that you want to use. The file in the script is relative to the root of the PHP agent. You can specify the absolute path if you prefer.
  4. Set the agent.proxy_ctrl_dir to the directory to use for initial control communication between the agent and the proxy. This directory contains the domain control socket, which the agent uses to start an AppDynamics node. This directory is where the agent gets the configuration for the node. The application user must have read permission on the proxy_ctrl_dir.

Whenever you install the PHP agent, the installer overwrites the runproxy script and the appdynamics_agent.ini file, but not the php.ini. If you re-install, you need to reset the agent.auto_launch_proxy setting in the appdynamics_agent.ini file before you restart the server.

Run the Proxy

Before any traffic runs on the instrumented server, execute the runProxy script to start the proxy.

The following lists the full set of options for the runProxy script. The proxy control directory is required. 

Usage: runProxy options -- proxyCommunicationDir logDirectory [jvmOption=jvmOptionValue [ jvmOption=jvmOptionValue [...] ]

Options:
  -r <dir>, --proxy-runtime-dir=<dir>     #Specifies proxy runtime directory
  -d <dir>, --proxy-dir=<dir>             #Specifies root proxy directory
  -j <dir>, --jre-dir=<dir>               #Specifies root JRE directory
  -v, --verbose                           #Enable verbose output
  -h,--help                               #Show this 

jvmOption
 -Dappdynamics.controller.hostName=<hostName>	         #Set the host name or IP address of the AppDynamics Controller                                                                                                                                    
 -Dappdynamics.controller.port=<port>                    #Set the HTTP(S) port of the AppDynamics Controller
 -Dappdynamics.agent.applicationName=<applicationName>   #Set the name of the logical business application
 -Dappdynamics.agent.tierName=<tierName>          		 #Set the name of the logical tier
 -Dappdynamics.agent.nodeName=<nodeName>                 #Set the name of the instrumented node
 -Dappdynamics.agent.accountName=<accountName>           #Set the account name used to authenticate with the Controller
 -Dappdynamics.agent.accountAccessKey=<accessKey>        #Set the account access key used to authenticate with the Controller
 -Dappdynamics.controller.ssl.enabled=<true>             #Set if the agent should use SSL (HTTPS) to connect to the Controller
 -Dappdynamics.agent.uniqueHostId=<uniqueHostId>         #Set a unique host ID for the App agents
JS

The following shows an example:

./proxy/runProxy -d ./proxy -r /tmp/appd/my_app/my_tier/my_node /tmp/proxy.communication /tmp/agentLogs


./proxy/runProxy /tmp/proxy.communication /tmp/agentLogs -Dappdynamics.controller.hostName=controller.appd.com -Dappdynamics.controller.port=8090 -Dappdynamics.agent.uniqueHostId=myUniqueHost 

./proxy/runProxy -d ./proxy /tmp/proxy.communication /tmp/agentLogs -Dappdynamics.agent.accountName=myAccount -Dappdynamics.agent.accountAccessKey=mYaCcEsSkEy

./proxy/runProxy -r /tmp/appd/app1/tier1/node1 /tmp/proxy.communication /tmp/agentLogs -Dappdynamics.agent.applicationName=my_app -Dappdynamics.agent.tierName=my_tier -Dappdynamics.agent.nodeName=my_node

A node is created when the agent first detects traffic on it.

Every time you reboot the server, you need to execute the runProxy script if you have opted to start the proxy manually.