WHM plugin registers but results in Error 500.
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
This is a test.
/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.-
Hey there! I'm not a developer, so my personal thoughts on this are going to be a bit limited. Error 127 is the Bash exit code for command not found. However, following these exact steps on a test server works fine for me - the plugin registers, and I'm able to see the "Hello World" page in WHM by visiting 0 -
Thanks, cPRex. If that's the case, then are there prerequisites that need to be on a server in order for the index.cgi to work? I was under the assumption the server setup was correct because cPanel's installation adds missing dependencies. We originally created an empty Linode using CentOS 7 (also Ubuntu 20.04 LTS during testing), and then installed using the command found in the " while attempting to send a message with the subject "[x-x-x-x.cprapid.com] The application "hello-world" has been registered with AppConfig for the service: whostmgr" info [whostmgrd] Internal Server Error: "GET /cpsess4690291321/cgi/hello-world/index.cgi HTTP/1.1" 500 Unable to execute (:/usr/local/cpanel/whostmgr/docroot/cgi/hello-world/index.cgi): No such file or directory We checked the directory to see if the file was copied over with appropriate permissions, and it was. 0 -
There are no prerequisites for these tools. The plugin and application system is built in to cPanel, and my testing was done on a brand new test machine with no special options selected during the installation. Since you're seeing the same issue on multiple machines, I would recommend making a ticket with out team so we can examine one of those. 0
Please sign in to leave a comment.
Comments
3 comments