Writing WHM Plugins

October 3, 2009 • By admincPanel

A WHM plugin is a simple CGI application that integrates with WebHost Manager. Any CGI language can be used, however Perl provides special functions that make permission handling much easier.

Plugin Location and Requirements

All WHM plugins must be placed at /usr/local/cpanel/whostmgr/docroot/cgi and must:

  • Be prefixed with addon_
  • End with .cgi
  • Be owned by root:root
  • Be globally readable/executable (chmod 755)

Required Comments

Every WHM plugin needs a special WHMADDON comment:

#WHMADDON:appname:Display Name

Where appname is the script name without addon_ and .cgi, and Display Name is what appears in the WHM Plugins menu.

Example Plugin

#!/usr/bin/perl
# WHMADDON:myplugin:My Plugin Name

use strict;
use CGI;

print "Content-type: text/html

";
print "<html><body>";
print "<h1>My WHM Plugin</h1>";
print "<p>Hello from my custom WHM plugin!</p>";
print "</body></html>";

Accessing Your Plugin

After placing the file in the correct location, your plugin will appear under the "Plugins" section in WHM. You may need to restart the cPanel service or wait a few minutes for it to appear.