Help - Search - Members - Calendar
Full Version: Red Hat Enterprise Apache Script Error
The Planet Forums > Operating Systems > Red Hat Linux
learner
Hi:

I am having problems getting scripts to work on server that runs Red Hat Enterprise 4.0. No panel is used to configure Apache.

The error I get when I call a Perl script is this:

QUOTE
(icon_cool.gif Exec format error : exec of <scriptname> failed


I have checked httpd.conf, and mod_perl.so is Loaded. ScriptAlias is also present for virtual site as.

QUOTE
ScriptAlias /cgi-bin/ /var/www/html/sitename/cgi-bin/


The Directory for the scriptalias path is as follows:

QUOTE
 
 Options  +ExecCGI
 SetHandler cgi-script
 AllowOverride All


Is there anything else needed in httpd.conf for it to call perl interpreter via browser. The script works when executed via command line.

Many Thanks mad.gif
ramprage
Try checking your /usr/local/apache/logs/suexec_log to see what else it says, make sure your script has execute permissions as well.
learner
QUOTE
/usr/local/apache/logs/suexec_log


I did a search and cannot find a suexec_log on the machine. I also have no /usr/local/apache directory on the RHN 4.0 server.

I configured sitename to have error_log and access_log under
/var/www/html/sitename/logs
which just has the access and error logs. Errors are loaded there when I call the script.

I looked under the main /var/log/httpd and only see access, error, ssl_access, ssl_error logs. No suexec_log there as well.

The apache httpd.conf file has the mod_suexec.so module loaded.

How do I check if suexec is even turned on at all :confused:

QUOTE
make sure your script has execute permissions as well.


That is the first thing I checked. Permissions is fine at 755 for the username.

Thank You
learner
QUOTE
SuExec


I can confirm that suExec is actually on by defalt as after stop and start httpd in the default /var/log/error_log I can see this message

QUOTE
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)


The wrapper came with the Red Hat Enterprise 4.0 distribution. However I am unable to check the settings used for this wrapper. From what I read of suEXEC from

http://httpd.apache.org/docs/1.3/suexec.html and
http://apache-server.com/tutorials/LPsuexec.html

I need to make sure my virtual host paths is under that of

QUOTE
--suexec-userdir=DIR  


Else user cgi requests will not work.

How can I check the settings used by this wrapper :confused:

I tried running it and in the suexec.log it keeps saying "too few arguments" .

Also does httpd has to be stop to check suexec wrapper settings :confused:

I also read about specifying the settings User, and Group in the directive. I tried that and when I start httpd, it fails giving an error "User cannot occur within section"

The default User and Group is set to "apache" . I have tried changing the script user and group ownership to apache, and executing them still fails.

I am clueless. Please help icon_sad.gif
ScottPO
On my RHES3 server, I use -V to get compile time options:

[root@plain root]# /usr/sbin/suexec -V
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="apache"
-D AP_LOG_EXEC="/var/log/httpd/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=500
-D AP_USERDIR_SUFFIX="public_html"
[root@plain root]#

This should work for you too.

-Scott
learner
QUOTE
/usr/sbin/suexec -V


Yes that worked and the settings are the same as yours. My paths for the virtualhost directive for the cgi-bin, and public_html are correct. However I had to add the SuexecUserGroup in the virtual host. However when I run the .pl script, I get this error message now:

QUOTE
failed to open log file
fopen: Permission denied
Premature end of script headers


This is dumped in the error_log file of the virtual host. I do not know why Apache wants to write to another log file. I have tried changing permission of the global /var/log/httpd of both the error_log, and access_log and the error is still there.

The .pl script runs on the command line without any errors reported. As I need help I paste below my virtualhost settings and the script code I am running

QUOTE

 SuexecUserGroup owner owner
 Servername localdomain.owner.net
 ServerAlias owner.net
 ScriptAlias /cgi-bin/ /var/www/html/owner/cgi-bin/
 DocumentRoot /var/www/html/owner/public_html
 ErrorLog /var/www/html/owner/logs/error_log
 CustomLog /var/www/html/owner/logs/access_log common
 LogLevel debug

 ServerSignature email
 
 DirectoryIndex index.html index.php index.htm index.shtml

 
   Options Indexes IncludesNOEXEC FollowSymLinks
 


 
    Options +ExecCGI
    SetHandler cgi-script
    AllowOverride All
 



QUOTE
#!/usr/bin/perl

#open pipe to ps
open PS, "/usr/bin/whoami |";

# loop for each file
my $user;
while() {
 chomp();
 $user = $_;
}
close PS;

print "Content-type: text/htmlnn";
print "

*Webserver is running as user $user*

";

exit;


PHP Issue:

I have also tried a simple PHP script and I also get errors in the error_log . The script is called index1.php with contents:

QUOTE
 echo 'Order Processed.n';
?>


The error follows:

QUOTE
PHP Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/owner/public_html/index1.php on line 2


Running on the command line as php index.php also gives this error which makes no sense to me as the syntax above look ok to me. I am on PHP/4.3.9

What is going on here icon_sad.gif

Please help icon_sad.gif

Thank You
learner
QUOTE
failed to open log file
fopen: Permission denied
Premature end of script headers


I have resolved this part for the perl script. The script is mounted on a windows partition and are saved as ascii unix format (Using UltraEdit). However when I transferred the script over to my red hat enterprise (same machine) I used cp command. For some reason the script was converted to binary format. I rewrote the script on the red hat virtual host cgi-bin using vi editor. saved and chmod 755. I run the new script and it works as I expect via the browser.

Does anyone how can I copy files from a windows mount point to linux and makes sure it copies as ascii or does red hat has a comand to convert the file to ascii format once copied over ?

I still am having the PHP issue. I am trying other things, but if anyone has any suggestion please let me know.

Thank You
learner
QUOTE
I still am having the PHP issue. I am trying other things, but if anyone has any suggestion please let me know.


I have been able to fix this. The machine I am using had the keyboard configured as US-International when RHE was installed. With such the keystroke for the tick and " key requires user to press twice to load it which was adding an extra character that is not visible unless the HEX version is viewed. Fixed this problem by changing the keyboard to US only. icon_smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.