PHP wrapped in CGI

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perryl7
Forum Newbie
Posts: 11
Joined: Tue Feb 08, 2005 1:32 pm

PHP wrapped in CGI

Post by Perryl7 »

My school's web server is not setup to handle PHP pages. I was told that I need to wrap them in a CGI script. I have never used CGI so I am not sure what I am doing wrong. I followed all of there instructions as far as I can tell and I still have a script error. Below is the code that I am trying to use:

#!/usr/local/bin/php
Content-Type: text/http

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<?php

print "test";

?>

</html>

If you have any idea what I am doing wrong, I would greatly appreciate the help.

Thanks,
-Cam
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

make sure the path to the php executable is correct... the following command may help you:

user@host: which php


if you are going for php and cli, i remember from the old perl days you need to output twice \r\n after the content type....

#!/usr/local/bin/php
<?php
echo "Content-Type: text/html \r\n\r\n";
?>
hehe :)


should be enough to get you started...
Perryl7
Forum Newbie
Posts: 11
Joined: Tue Feb 08, 2005 1:32 pm

Post by Perryl7 »

I tried it that way and with multiple variations and still no luck. It would be nice if my school would provide support since they provide the service.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

also make sure that nobody/www-data is allowed to execute that script (or was it read the script)... cgi days are so 90ies :)
Post Reply