Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi in general works, php does not! 1

Status
Not open for further replies.

copton

Programmer
Aug 8, 2001
7
DE
hi
although having installed the php module my php scripts do not work. cgi in general works, as there are no probleme with perl scripts.
but when executing a php-script i get an internal server error and the following entry in error_log:
[error] (8)Exec format error: exec of /usr/local/httpd/htdocs/con.php failed
[error] [client 127.0.0.1] Premature end of script headers: /usr/local/httpd/htdocs/con.php
the script is redused to the following lines:
<?php
header(&quot;Content-type: text/plain&quot;);
echo (&quot;Hello World!&quot;);
?>
I RTFM, but still don't know what it could be. plz help me if you can.

regards
copton
 
Hi,



Make sure you have the following lines in the appropriate sections of your httpd.conf file :



LoadModule php4_module libexec/libphp4.so



AddModule mod_php4.c



AddType application/x-httpd-php .php .php4



Hope this helps

Rgds





 
Are you trying to execute your PHP scripts the same way you would execute a CGI? That's not the idea!

PHP scripts are merely passed through the Apache process, the same as HTML, except everything inside <?php ?> tags gets parsed. PHP is more analogous to Server-Side Includes than it is to CGI. So, my point is, if you are placing PHP scripts inside your /cgi-bin directory and trying to call them as an executable, that's not going to work. Just make sure you have the correct directives in httpd.conf, as mentioned above, and then put your script anywhere in your normal document root.

OK, for those who want to correct me, yes executing PHP as a CGI will work if you use PHP as a shell scripting language, but that's a totally different usage:

1. You don't need the <?php ?> tags

2. You need the standard shebang (#!/usr/local/bin/php, or whatever is the path to your executable) at the beginning of your script

3. You need to have PHP compiled as a binary executable, not as an Apache module

Using PHP as a shell scripting language is not the most common use of PHP, and definitely not as efficient a method of web application scripting.
 
hi







@ifincham: thanks a lot for you help. after adding the LoadModule, AddModule and AddType lines to httpd.conf i tried it but failed first. thanks to rycamor i then removed php from the list of cgi handlers and now it works!









@rycamor: thank you too, for your elaboration about the difference of cgi/perl and (server mod) php. as mentioned above this was very helpful for me.















may the force be with you.







regards







copton















 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top