Hi Jamie,
I am running WHMCS 4.5.1 with FCGId in Virtualmin PRO and when I process an order and choose to Create, suspend, enable (which directly call the Virtualmin API) I am recieving a nice 500 Error after a range of seconds (so it isn't a timeout issue).
It appears that the virtualmin api is restarting fcgid during the API run.
I am not sure if this is a bug or working as designed but here are my findings...
Call create-domain.pl :
[Fri Jun 10 18:22:05 2011] [warn] [client 24.16.194.164] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://xtremeservices.net/billing/admin/orders.php?action=view&id=15 [Fri Jun 10 18:22:05 2011] [error] [client 24.16.194.164] Premature end of script headers: orders.php, referer: http://xtremeservices.net/billing/admin/orders.php?action=view&id=15 [Fri Jun 10 18:22:05 2011] [emerg] mod_fcgid: server is restarted, pid 30459 must exit [Fri Jun 10 18:22:05 2011] [emerg] (22)Invalid argument: mod_fcgid: can't get lock in pid 30459
Call disable-domain.pl : [Fri Jun 10 18:23:23 2011] [warn] [client 24.16.194.164] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Fri Jun 10 18:23:23 2011] [error] [client 24.16.194.164] Premature end of script headers: clientshosting.php, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Fri Jun 10 18:23:23 2011] [emerg] mod_fcgid: server is restarted, pid 30889 must exit [Fri Jun 10 18:23:23 2011] [emerg] (22)Invalid argument: mod_fcgid: can't get lock in pid 30889
Call enable-domain.pl : [Fri Jun 10 18:24:27 2011] [warn] [client 24.16.194.164] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Fri Jun 10 18:24:27 2011] [error] [client 24.16.194.164] Premature end of script headers: clientshosting.php, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Fri Jun 10 18:24:28 2011] [emerg] mod_fcgid: server is restarted, pid 31039 must exit [Fri Jun 10 18:24:28 2011] [emerg] (22)Invalid argument: mod_fcgid: can't get lock in pid 31039
Call modify-domain.pl : - Upgrade Package : No errors!! - Change Password : No errors!!
Call delete-domain.pl : **No 500 error but looks like the restart is occuring here too. [Fri Jun 10 18:29:08 2011] [emerg] mod_fcgid: server is restarted, pid 31171 must exit [Fri Jun 10 18:29:08 2011] [emerg] (22)Invalid argument: mod_fcgid: can't get lock in pid 31171
Thx,
~Jeremy
Comments
Submitted by andreychek on Fri, 06/10/2011 - 20:56 Comment #1
Howdy -- Jamie may have some additional thoughts on what's going on, but as an initial troubleshooting step, I'm curious if you see the same issue if WHMCS is running under CGI mode.
You can switch it to CGI mode by going into Server Configuration -> Website Options, and changing the PHP Execution mode to "CGI".
Submitted by JamieCameron on Fri, 06/10/2011 - 21:03 Comment #2
Are you running WHMCS on the same system as Virtualmin? If so, the issue may be that WHMCS is being killed when apache is restarted for the domain creation.
Submitted by xtremeservices on Fri, 06/10/2011 - 21:04 Comment #3
Howdy Eric,
I did try that and recieved a bunch more errors : ) so I figured there has to be a way to get it to work with FCGId.
[Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] Security Alert! The PHP CGI cannot be accessed directly., referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] , referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164]
This PHP CGI binary was compiled with force-cgi-redirect enabled. This, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] means that a page will only be served up if the REDIRECT_STATUS CGI variable is, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] set, e.g. via an Apache Action directive.
, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164]
For more information as to why this behaviour exists, see the manual page for CGI security.
, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164]
For more information about changing this behaviour or re-enabling this webserver,, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] consult the installation file that came with this distribution, or visit , referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] the manual page.
, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] Premature end of script headers: php5.cgi, referer: http://xtremeservices.net/billing/admin/orders.php
~Jeremy
Submitted by xtremeservices on Fri, 06/10/2011 - 21:08 Comment #4
I am running WHMCS on the same system I am trying to provision to.
Is there a way to send confirmation back to the script that called the API of success prior to restarting Apache?
~Jeremy
Submitted by JamieCameron on Fri, 06/10/2011 - 23:00 Comment #5
Actually, Virtualmin shouldn't need to restart Apache at all - it should only need to signal a configuration reload. You can verify that this is being done by going to Webmin -> Servers -> Apache Webserver -> Module Config, and making sure "Command to apply configuration" is set to something like "apache2ctl graceful"
Submitted by xtremeservices on Fri, 06/10/2011 - 23:06 Comment #6
Hi Jamie,
I checked my settings and it was set to : /usr/sbin/apache2ctl graceful
The attachment is of all my settings incase you have other suggestions.
Thx!
~Jeremy
Submitted by JamieCameron on Fri, 06/10/2011 - 23:55 Comment #7
That looks OK ..
One more question - does the domain you are creating have SSL enabled? Because this requires an Apache restart to apply, which may be causing the problem.
Submitted by xtremeservices on Sat, 06/11/2011 - 00:05 Comment #8
SSL is not enabled for the domain.
Something interesting I tracked down, the graceful setting was patched recently to kill all fcgid processes... Lame...
https://issues.apache.org/bugzilla/show_bug.cgi?id=48949
~Jeremy
Submitted by xtremeservices on Sat, 06/11/2011 - 01:35 Comment #9
Well I have awesome news!!!!
I changed the Command to Apply Configuration to : /usr/sbin/apache2ctl -t (Just tests the syntax of the config)
Now I can successfully provision on the same host. I have reproduced the provisioning 3 times in a row and every time I check the Apache2 server module the new domain is listed. No fcgid processes were terminated or SIGUSER1 recieved in the /var/log/apache2/error.log during the provisioning!!! : ) Best of All, I get a Service Created Successfully on WHMCS and no 500 error.
Can you think of any headaches this will cause?
~Jeremy
Submitted by JamieCameron on Sat, 06/11/2011 - 02:45 Comment #10
This could cause problems, as it means the new domain won't be applied in the apache configuration and so may not be accessible.
One work-around would be to change the apply command to something like :
(sleep 5 ; apache2ctl graceful) >/dev/null 2>&1 </dev/null &
This will run it in the background after a 5 second delay, during which time the WHCMS provisioning should have completed.
Submitted by xtremeservices on Sat, 06/11/2011 - 09:11 Comment #11
Hi Jamie,
Unfortunately with the sleep 5 the fcgid process is still being killed prior to being able to communicate the success back to whmcs.
[Sat Jun 11 06:56:07 2011] [warn] [client 24.16.194.164] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Sat Jun 11 06:56:08 2011] [error] [client 24.16.194.164] Premature end of script headers: clientshosting.php, referer: http://xtremeservices.net/billing/admin/clientshosting.php?userid=1&host... [Sat Jun 11 06:56:08 2011] [emerg] mod_fcgid: server is restarted, pid 2741 must exit [Sat Jun 11 06:56:08 2011] [emerg] (22)Invalid argument: mod_fcgid: can't get lock in pid 2741
I think you have a missing backquote on the right hand side.
~Jeremy
Submitted by xtremeservices on Sat, 06/11/2011 - 11:11 Comment #12
Ok, I am ready to TRY CGI : )
I have googled my brains out trying to find an example of settings CGI up with WHMCS and Matt at WHMCS says that nothing needs to be changed in WHMCS. So this means that I am on my own as far as setting up the CGI so I don't get these errors:
[Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] Security Alert! The PHP CGI cannot be accessed directly., referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] , referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] This PHP CGI binary was compiled with force-cgi-redirect enabled. This, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] means that a page will only be served up if the REDIRECT_STATUS CGI variable is, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] set, e.g. via an Apache Action directive., referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] For more information as to why this behaviour exists, see the manual page for CGI security., referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] For more information about changing this behaviour or re-enabling this webserver,, referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] consult the installation file that came with this distribution, or visit , referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] the manual page., referer: http://xtremeservices.net/billing/admin/orders.php [Fri Jun 10 18:00:33 2011] [error] [client 24.16.194.164] Premature end of script headers: php5.cgi, referer: http://xtremeservices.net/billing/admin/orders.php
Any documentation you could point me to on the refer stuff mentioned above or any suggestions are greatly appreciated.
~Jeremy
Submitted by JamieCameron on Sat, 06/11/2011 - 12:27 Comment #13
Sorry, the command should have been :
(sleep 5 ; apache2ctl graceful) >/dev/null 2>&1 </dev/null &
Did you switch to CGI mode for PHP on the "Website Options" page?
Submitted by andreychek on Sat, 06/11/2011 - 13:05 Comment #14
WHMCS should work in CGI mode -- the errors you're seeing suggest a configuration issue of some sort.
What is the output of this command:
dpkg -l 'php*
Also, can you paste the contents of the file "$HOME/cgi-bin/php5.cgi" into this request (that file will exist after switching to CGI mode)?
Thanks!
Submitted by xtremeservices on Sat, 06/11/2011 - 17:38 Comment #15
Just for record Jamie, your last suggestion works great with WHMCS on account creations as long as the sleep 5 is increased to 20. (atleast on my system)
~Jeremy
Submitted by xtremeservices on Sat, 06/11/2011 - 17:36 Comment #16
Eric (almost called you Andrey lol), here is what you requested:
dpkg :
root@mars:~# dpkg -l 'php*' Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-===================-====================================================== ii php-pear 5.3.2-1ubuntu4.9 PEAR - PHP Extension and Application Repository un php-xml-util (no description available) un php4-pear (no description available) ii php5 5.3.2-1ubuntu4.9 server-side, HTML-embedded scripting language (metapac ii php5-adodb 5.04-4build2 Extension optimising the ADOdb database abstraction li ii php5-auth-pam 0.4-10ubuntu1 A PHP5 extension for PAM authentication ii php5-cgi 5.3.2-1ubuntu4.9 server-side, HTML-embedded scripting language (CGI bin ii php5-cli 5.3.2-1ubuntu4.9 command-line interpreter for the php5 scripting langua ii php5-common 5.3.2-1ubuntu4.9 Common files for packages built from the php5 source ii php5-curl 5.3.2-1ubuntu4.9 CURL module for php5 un php5-dev (no description available) ii php5-exactimage 0.7.4-3ubuntu2 fast image manipulation programs (PHP bindings) ii php5-ffmpeg 0.6.0-1build3 audio and video support via ffmpeg for php5 ii php5-gd 5.3.2-1ubuntu4.9 GD module for php5 ii php5-imagick 2.1.1RC1-1build3 ImageMagick module for php5 un php5-json (no description available) ii php5-mcrypt 5.3.2-0ubuntu1 MCrypt module for php5 un php5-mhash (no description available) ii php5-mysql 5.3.2-1ubuntu4.9 MySQL module for php5 un php5-mysqli (no description available) ii php5-sasl 0.1.0-1ubuntu1 Cyrus SASL extension for PHP 5 ii php5-suhosin 0.9.29-1ubuntu1 advanced protection module for php5 un phpapi-20090626 (no description available) un phpmyadmin (no description available)
Here is the ~/cgi-bin/php5.cgi
!/bin/bashPHPRC=$DOCUMENT_ROOT/../etc/php5 export PHPRC umask 022 SCRIPT_FILENAME=$PATH_TRANSLATED export SCRIPT_FILENAME exec /usr/bin/php5-cgi
~Jeremy
Submitted by andreychek on Sat, 06/11/2011 - 19:35 Comment #17
That all looks good -- you have the correct PHP packages installed, and the php5.cgi file is correct.
When in CGI mode -- are you able to browse other sections of WHMCS... is it just that one area that doesn't work?
Or do you get errors on any WHMCS screen when in CGI mode?
Submitted by xtremeservices on Sat, 06/11/2011 - 19:49 Comment #18
I can get to most of WHMCS it is just certain areas that I am unable to.
This is an example link that errors in CGI : http://xtremeservices.net/cgi-bin/php5.cgi?action=view&id=18
Here is the same link under FCGId : http://xtremeservices.net/billing/admin/orders.php?action=view&id=18
What could be causing the link to be re-written?
~Jeremy
Submitted by andreychek on Sat, 06/11/2011 - 19:58 Comment #19
This is an example link that errors in CGI
Aha! That's the problem.
You should never end up with a link that has "cgi-bin/php5.cgi" in it. If you ever see that -- that link is incorrect.
The key, then, is to figure out what's triggering that problem. There's a few different causes of that, ranging from system configuration problems to incompatibilities with the web application.
Here's where I would start -- Ubuntu 10.04 uses PHP 5.3. We've occasionally seen "pathinfo" issues with that.
Try editing your Virtual Servers php.ini file (in $HOME/etc/php.ini), look for "cgi.fix_pathinfo", and set the value to 0. When you're done, the line it's on should look like this:
cgi.fix_pathinfo=0
Then, try logging out of WHMCS, go back in, and see if that works correctly for you.
Submitted by xtremeservices on Sat, 06/11/2011 - 20:40 Comment #20
BINGO!!!
Thx Eric!
Interesting, it was set to Default and I had to turn it off.
~Jeremy
Submitted by andreychek on Sat, 06/11/2011 - 21:04 Comment #21
Well, not all PHP applications are compatible with all PHP settings.
Also, most developers test their PHP apps with mod_php rather than CGI. Mod_php is more tolerant of certain settings such as this one, though it's less secure in a multi-user environment.
In any case -- I'm glad CGI mode is working for you.
Does that mean you're now able to process orders in WHMCS?
Submitted by xtremeservices on Sat, 06/11/2011 - 21:58 Comment #22
Hi Eric,
YES, I am able to do everything I was hoping to!!
Thank you for your assistance!
~Jeremy
Submitted by Issues on Sun, 06/26/2011 - 01:31 Comment #23
Automatically closed -- issue fixed for 2 weeks with no activity.