Page 1 of 1

PHP wrapped in CGI

Posted: Thu Feb 10, 2005 4:24 pm
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

Posted: Thu Feb 10, 2005 5:21 pm
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...

Posted: Fri Feb 11, 2005 2:55 pm
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.

Posted: Fri Feb 11, 2005 3:50 pm
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 :)