I need to use some specific hosting server for a project and I have to use one of my Perl scripts there (basically I use Perl for most of my codes), but there is a big issue with this. The web masters and admins seem they don't have enough knowledge to resolve the problems. the config is like this:
Apache/2.0.54 (Debian GNU/Linux) FrontPage/5.0.2.2635 mod_python/3.1.3 Python/2.3.5 PHP/4.3.10-16 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_perl/1.999.21 Perl/v5.8.4
The control Panel is "Confixx", server is Debian Linux.
whenever I try to run a simple test on the cgi-bin directory so I get the perl to work first, something as simple as something like this:
----
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
print "testing.. $ENV{'DOCUMENT_ROOT'}";
----
Every time I get the error saying "Premature End of Script x.cgi, Error 500" along some other text.
I don't have shell access to the server and no telnet access. I have tried every of solutions I have found on web, nothing have yet worked for me.
I know path to the perl, send mail exists and works, I have changed permissions to 755 and 777 without any luck yet, tried sending explicitly as ASCII, again no luck. tried several other simple test scripts, no results so far.
access log is not much descriptive, it contains only the error number and some other useless (for me) info.
So, please somebody give me some helps, hints, on how can I step by step try to resolve this problem.
Thanks a lot!
Paymaan.
PC plain text and Unix plain text have different end of line/return characters. On the right servers, if I save a script in PC format (NotePad) it will error every. single. time, with the same obscure error. However, if I save the file in Unix format, no problems.
This is one of the reasons I use HomeSite, which has the ability to set the output file format, PC or Unix. Try to open one of my scripts in NotePad and you get those awful square boxes without any formatting.
So look into that, I'm sure you tried removing the "use" line, that would be the only other thing I see. Adobe killed HomeSite in favor of Dreamweaver <rolls eyes> so you may not find it, but there are many editors that can save in Unix format, some of them free.
I have removed the first line for test, and saved in Unix format, the same problem happens.
One question, is it possible that FTP server prevents ASCII downloads, even if the user sets the mode to ASCII?
Paymaan.
Paymaan.
[edited by: Paymaan at 8:37 am (utc) on Oct. 18, 2008]
I also wrote a shell script (script.sh I mean) as a cgi and uploaded in the same directory and it didn't work either. So somebody please help me find where in the server and which configuration might be wrong, Just know that they are also using suExec on this server.
Paymaan.
[edited by: phranque at 3:16 am (utc) on Oct. 20, 2008]
Imagine somebody has installed the Debian Sarge, Perl and mod Perl along Confixx on a server (also python, php, ssl, and I know php works fine).
Now tell me if still CGI is disabled (all cgi possibly, not only perl), with a premature end of script error + a 500 internal server error, what steps do you take to find the problem?
How can I enable this, if I have root access? and what if I do not have root access?
Paymaan.
abot checking apache config, is this the same config I normally use to enable cgi in other linux OSes, like ubuntu and SuSE? But there when CGI is not enable I do not get a "Premature End of Script", just a Internal Server error.
Anyway, which log file should I ask root to copy for me? is there a directive he can give me direct access to my own error logs related to my own virtual host? how can he enable this?
Paymaan.
I will ask the admin for the error file in the path you've mentioned, after weekend. I can see acceess log, but it doesn't say much about errors, so I have to check the error log.
Changing the host provider, unfortunatley is not an option, if it was, I had my own host provider which is one of the best I have used since 1999!
Another option, which might be a little expensive is to set up and put a dedicated server there with full access. What Linux type do you suggest, and what control panel (better to be free and open source), and other environment do you suggest? Is there any simple step by step guide somewhere in the forum telling how to set up a hosting?
Regards,
Paymaan.
Now still the error level is something it just gives the same basic "Premature end of scripts". I guess now I can ask admin to change the level of my error log, so what shoudl I put in the config (and where) so I can get detailed info on this error?
I also tried putting something in .htaccess to enable cgi, <directory> and Options ExecCGI, but it seems .htaccess is prevented from running those as I got errors for .htaccess.
Actually I went to the hosting center and worked with the admin to find a problem, he is now willing to help, and what I saw was that Confixx adds some includes to the Apache2 configs to build virtual hosts and those are very simple, so I guess I have to understand what to add to enabale everything missed.
and is there any other message in the error file related to this HTTP GET request besides the "Premature end of script headers:" or is there also a "Permission denied:" or "No such file or directory:" or any other error listed?
usually if the only error is "Premature end of script headers:" the script is running but ended without sending headers.
---
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use Config;
print "Content-type: text/html\n\n";
if ($Config{usethreads}) {
print "has thread support\n"
}
use Config qw(myconfig config_sh config_vars config_re);
print myconfig();
print config_sh();
print config_re();
config_vars(qw(osname archname));
----
Then as a sample, the error line is something like this:
[Tue Oct 28 08:27:17 2008] [error] [client [ip]] Premature end of script headers: test.pl
The permissions for the script is 755, and I have tried running the script both outside the cgi-bin and inside, the same happens.
I finally managed to find an answer to the problem resolving it and here is the reason:
it seems suexec was preventing the scripts from being executed. I checked the suexec error log with admin and this line was there:
[date time]: uid: (1504/userid) gid: (1504/1504) cmd: test.pl
[date time]: command not in docroot (/home/www/userid/html/cgi-bin/test.pl)
So I asked the admin to remove the line in my virtual host config containing this:
suexec userid userid
which was the reason. I guess there are other methods like setting the correct id for this virtual host, but I am not familiar with them, and I don't need the suexec to control my cgi-bin, and my site doesn't hold sensitive data, so the current solution will do fine for the moment.
Paymaan.
i would suggest getting your entire virtual host configuration and making sure you understand every directive in there.
How I did find the resolution without having direct access to root was that first I went there to the admin and fixed the error log in my virtual host setting to some file "inside" my own hosting directory, so I could read it. Then later asked my admin to give me a copy of Apache.conf, Confixx.conf (and all realted configs) along my own Virtual Host config files.
I studied all of them, tried putting "AllowOverride All" inside of it so I could change things using my ".htaccess" file. Then when none gave an answere, as a last resort, I asked admin to disable suexec, and then I found this suexec error log telling the other error, and I removed the line containing suexec command inside my own virtual host config.
he other part of site may still have the problem, but now I know what is the source of problem.
It took a lot of time with the no-access way I had, but at least we got some results.
Thanks,
Paymaan.