Hello,
I am trying to develop an extension for cPanel. I am attempting to create a simple plugin to get started on. The installation script does not produce errors, I can see the plugin is registered to the AppConfig, the buttons to access the plugin are there, and the icon is working.
However, when I try to access the plugin, it immediately fires a 500 error. Looking at the error_log, it shows the following:
[2023-01-17 20:41:24 +0000] warn [whostmgrd] The subprocess (/usr/local/cpanel/whostmgr/docroot/cgi/hello-world/index.cgi) exited with an error (ID 255821550571458): The subprocess reported error number 127 when it ended.
[2023-01-17 20:41:24 +0000] info [whostmgrd] Internal Server Error: "GET /cpsess7098692916/cgi/hello-world/index.cgi HTTP/1.1" 500 Internal Error (ID 255821550571458)
I tried looking up that error, but I could not find anything. Can you help me figure out what is causing this error 500? Below you will find the files and scripts that we use to install the plugin (from the /root/ directory). Ideally, I would like to make the WHM plugin using as much PHP as possible (as that is what I am mostly familiar with), but if that's not an option, please let me know.
/root/hello-world/hello-world.conf
# The name of the plugin
name=hello-world
# Service that will run the plugin/app
service=whostmgr
# User to run the plugin as (root)
user=root
# URL where the plugin program will be stored/called from (relative to /usr/local/cpanel/docroot/)
url=/cgi/hello-world/index.cgi
# Required ACL's
acls=any
# Display name within the WHM (Plugins section)
displayname=Hello World
# URL to show in WHM (again, relative to where the plugin/app is installed)
entryurl=hello-world/index.cgi
# Icon that will show up in WHM => Plugins section
icon=hello-world.png
# Target (frame). In 64 and later, this defaults to _blank. Use _self to open within WHM
target=_self
/root/hello-world/index.cgi
#!/usr/local/cpanel/3rdparty/bin/php-cgi
<?php
require_once('/usr/local/cpanel/php/WHM.php');
WHM::header('Hello World Plugin',0,0);
?>
<p>This is a test.</p>
<?php
WHM::footer();
/root/install-whm.sh
#/usr/bin/bash
echo "Installing Hello World Plugin ..."
# Extract tar.gz to hello-world
if [ ! -d /root/hello-world ]
then
mkdir /root/hello-world
chmod 755 /root/hello-world
fi
tar -xzf ./hello-world.tar.gz -C ./hello-world --strip-components=1
# Check for and create the directory for plugin and AppConfig files.
if [ ! -d /var/cpanel/apps ]
then
mkdir /var/cpanel/apps
chmod 755 /var/cpanel/apps
fi
# Check for and create the directory for plugin CGI files.
if [ ! -d /usr/local/cpanel/whostmgr/docroot/cgi/hello-world ]
then
mkdir /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
chmod 755 /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
fi
# Check for and create the directory for plugin template files.
# if [ ! -d /usr/local/cpanel/whostmgr/docroot/templates/hello-world ]
# then
# mkdir /usr/local/cpanel/whostmgr/docroot/templates/hello-world
# chmod 755 /usr/local/cpanel/whostmgr/docroot/templates/hello-world
# fi
# Check for and create the directory for other files.
# if [ ! -d /usr/local/cpanel/3rdparty/hello-world ]
# then
# mkdir /usr/local/cpanel/3rdparty/hello-world
# chmod 755 /usr/local/cpanel/3rdparty/hello-world
# fi
# Register the plugin with AppConfig.
/usr/local/cpanel/bin/register_appconfig ./hello-world/hello-world.conf
# Copy plugin files to their locations and update permissions.
/bin/cp ./hello-world/index.cgi /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
chmod 755 /usr/local/cpanel/whostmgr/docroot/cgi/hello-world/index.cgi
# /bin/cp -R -f ./templates/* /usr/local/cpanel/whostmgr/docroot/templates/hello-world
/bin/cp ./hello-world/hello-world.png /usr/local/cpanel/whostmgr/docroot/addon_plugins
# Delete unzipped files and tar.gz
rm -r ./hello-world
# rm -f ./hello-world.tar.gz
# Finish
echo 'Hello World successfully installed'
Thanks in advance.
I am trying to develop an extension for cPanel. I am attempting to create a simple plugin to get started on. The installation script does not produce errors, I can see the plugin is registered to the AppConfig, the buttons to access the plugin are there, and the icon is working.
However, when I try to access the plugin, it immediately fires a 500 error. Looking at the error_log, it shows the following:
[2023-01-17 20:41:24 +0000] warn [whostmgrd] The subprocess (/usr/local/cpanel/whostmgr/docroot/cgi/hello-world/index.cgi) exited with an error (ID 255821550571458): The subprocess reported error number 127 when it ended.
[2023-01-17 20:41:24 +0000] info [whostmgrd] Internal Server Error: "GET /cpsess7098692916/cgi/hello-world/index.cgi HTTP/1.1" 500 Internal Error (ID 255821550571458)
I tried looking up that error, but I could not find anything. Can you help me figure out what is causing this error 500? Below you will find the files and scripts that we use to install the plugin (from the /root/ directory). Ideally, I would like to make the WHM plugin using as much PHP as possible (as that is what I am mostly familiar with), but if that's not an option, please let me know.
/root/hello-world/hello-world.conf
# The name of the plugin
name=hello-world
# Service that will run the plugin/app
service=whostmgr
# User to run the plugin as (root)
user=root
# URL where the plugin program will be stored/called from (relative to /usr/local/cpanel/docroot/)
url=/cgi/hello-world/index.cgi
# Required ACL's
acls=any
# Display name within the WHM (Plugins section)
displayname=Hello World
# URL to show in WHM (again, relative to where the plugin/app is installed)
entryurl=hello-world/index.cgi
# Icon that will show up in WHM => Plugins section
icon=hello-world.png
# Target (frame). In 64 and later, this defaults to _blank. Use _self to open within WHM
target=_self
/root/hello-world/index.cgi
#!/usr/local/cpanel/3rdparty/bin/php-cgi
<?php
require_once('/usr/local/cpanel/php/WHM.php');
WHM::header('Hello World Plugin',0,0);
?>
<p>This is a test.</p>
<?php
WHM::footer();
/root/install-whm.sh
#/usr/bin/bash
echo "Installing Hello World Plugin ..."
# Extract tar.gz to hello-world
if [ ! -d /root/hello-world ]
then
mkdir /root/hello-world
chmod 755 /root/hello-world
fi
tar -xzf ./hello-world.tar.gz -C ./hello-world --strip-components=1
# Check for and create the directory for plugin and AppConfig files.
if [ ! -d /var/cpanel/apps ]
then
mkdir /var/cpanel/apps
chmod 755 /var/cpanel/apps
fi
# Check for and create the directory for plugin CGI files.
if [ ! -d /usr/local/cpanel/whostmgr/docroot/cgi/hello-world ]
then
mkdir /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
chmod 755 /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
fi
# Check for and create the directory for plugin template files.
# if [ ! -d /usr/local/cpanel/whostmgr/docroot/templates/hello-world ]
# then
# mkdir /usr/local/cpanel/whostmgr/docroot/templates/hello-world
# chmod 755 /usr/local/cpanel/whostmgr/docroot/templates/hello-world
# fi
# Check for and create the directory for other files.
# if [ ! -d /usr/local/cpanel/3rdparty/hello-world ]
# then
# mkdir /usr/local/cpanel/3rdparty/hello-world
# chmod 755 /usr/local/cpanel/3rdparty/hello-world
# fi
# Register the plugin with AppConfig.
/usr/local/cpanel/bin/register_appconfig ./hello-world/hello-world.conf
# Copy plugin files to their locations and update permissions.
/bin/cp ./hello-world/index.cgi /usr/local/cpanel/whostmgr/docroot/cgi/hello-world
chmod 755 /usr/local/cpanel/whostmgr/docroot/cgi/hello-world/index.cgi
# /bin/cp -R -f ./templates/* /usr/local/cpanel/whostmgr/docroot/templates/hello-world
/bin/cp ./hello-world/hello-world.png /usr/local/cpanel/whostmgr/docroot/addon_plugins
# Delete unzipped files and tar.gz
rm -r ./hello-world
# rm -f ./hello-world.tar.gz
# Finish
echo 'Hello World successfully installed'
Thanks in advance.