Search code examples
cpanelnewrelicpyrocms

Want to add New Relic to Pyrocms per domain on cPanel


I have New Relic all set-up and running nicely on my centOS server running cPanel. I want to now add more applications so I have one per domain. The issue is i'm using PyroCMS Pro, so each site does not have its own directory, only a template folder. I have seen you can add php.ini files or .htacess files but only in the root of each site which isn't going to help me with Pyrocms. Any direction on this is appreciated.


Solution

  • I believe there are 2 steps to do this,

    first set an environment variable for the host;

    SetEnvIf Host ^www\.example\.com$ domain1
    SetEnvIf Host ^www\.anotherexample\.com$ domain2
    

    Step 2 is to add the conditionals for each domain

    <IfDefine domain1>
        php_value newrelic.appname "Domain 1 app"
    </IfDefine>
    
    <IfDefine domain2>
        php_value newrelic.appname "App for other domain"
    </IfDefine>
    

    Got info from here: http://jennyandlih.com/using-apaches-ifdefine-dev-and-production-environments and new relics example: https://docs.newrelic.com/docs/php/per-directory-settings#htaccess-apache

    One caveat is for a large number of domains there will be a large number of conditionals.