Install NewRelic on LiteSpeed Server

Install NewRelic on LiteSpeed Server


3 min read

Hi, In this article, I'm going to show you how to install NewRelic APM on an OpenLiteSpeed Server due to the lack of the original document, Later, I'll share some of the settings that I use for any project.

Setup Data

First, go to your NewRelic panel and click on Add Data menu item, Then click Guided Installation, Then click on APM(Application Monitoring) tab and select PHP, Then click on Begin Installation.

Install APM Agent

After the last step, You will see something like this:

In the Your account step, choose the account that you want to continue with.

Then give a name for your application in the Give your application a name step.

Install Agent

Choose your distro package manager or Docker/tar archive to install the NewRelic agent. I'll go with apt, and here's the tricky part: NewRelic masses with OpenLiteSpeed!

After choosing apt as our package manager, you will see something like this:

Run the First, Second, Third, and Fourth commands one by one.

After the fourth command, go to /usr/lib/newrelic-php5 and open with your text editor, search add_to_path and you’ll find a list of them, add paths for your installed LiteSpeed PHPs.

For Example:

add_to_path /usr/local/lsws/lsphp81/bin
add_to_path /usr/local/lsws/lsphp82/bin

Save it and close your editor, and then run:

newrelic-install install

You will be asked for License Key, enter it, and after that, you'll be asked to select PHP versions, you can select one by one or type all and hit enter.

Now restart your web service with these two commands:

systemctl restart lsws
killall lsphp

Now you can go for Step 4 and install log metrics and infrastructure tools for your server.

Now your NewRelic is installed successfully, and it's time to configure settings, some of them are required, and some of them are good for better usage of NewRelic.


If you want to set up the license key for any LiteSpeed PHP, you can go to /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/ and edit newrelic.ini file.

Find newrelic.license and place your license key in front of the variable.

If you want to set up the application name for all websites and the whole server, you can edit newrelic.appname in `/usr/local/lsws/lsphp81/etc/php/8.1/mods-available/newrelic.ini` file.

Customize Application Name for each website

You can refer to the original document for naming your applications individually, and for LiteSpeed, you can go with the LiteSpeed document, for CyberPanel you can add the below config to your vHost configuration:

phpIniOverride  {
  php_value newrelic.appname "Your website name"

If you have any questions regarding setting up NewRelic on LiteSpeed servers, please feel free to contact me through comments or other ways.