Question

I'm trying to write a WHM plugin (running into WHM plugins section so that it runs for root and resellers, not in cPanel). The script is located at /usr/local/cpanel/whostmgr/docroot/cgi and named as addon_httpcli.php so you may understand what I'm talking about.

The issue is this WHM environment has its own PHP binary and it seems compiled with less modules/functions enabled unlike most web servers. Here's what I've tried until now:

  • cURL (curl_init() not recognized so I guess they didn't enable cURL)
  • socket_create() and related functions (function called but not sending custom HTTP headers so I bet they didn't enable something somewhere...)
  • As a simple file_get_contents("http://www.google.com/"); worked I tried coupling it with stream context to send custom headers and a POST request it leads to limitless wait time so I bet they may have disabled something here too...

In short, I'm stuck at what to do exactly to solve this issue and finish my plugin. So maybe a smart coder has encountered a similar nightmare in the past and could point me to his/her solution.

Was it helpful?

Solution

Well you could use the HTTP_Request2 PEAR package. It is quite good and supports all HTTP-methods. I guess I call this the minimal-invasive solution.

If you want to use cURL there is another way (untested, but it should work):

Edit /var/cpanel/easy/apache/profile/makecpphp.profile.yaml and search for the entries with "Curl" in it. Just change the "0" to "1". After saving the file you should be able re-compile the cPanel PHP with /scripts/makecpphp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top