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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache with PHP

Status
Not open for further replies.

samit700

Programmer
Sep 23, 2003
52
US
Hello everyone,

I have recently installed Apache and PHP packages on my computer. I am trying to run php as CGI. I have added all the right configration directives to httpd.conf file. But I am unable to get the php engine working with apache. I have tried so many things, but I keep getting the same error. It seems many people get this eror initially. I have even copy-pasted someone's code but it still doesn't work (works on his computer). I have spent so much time figuring out this and also tried so many different installations of Apache, that I am thinking of installing a different web server altogether. But I still would like toknow what is going wrong. This is what I put in my httpd.conf file:

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php3 .php
AddType application/x-httpd-php3 .php3
Action application/x-httpd-php3 "/php/php.exe"

The location of files and setup also looks right. I get these errors.

With url Internal Server Error
Logs: C:/php/test.php is not executable; ensure interpreted scripts have "#!" first line
Bad file descriptor: don't know how to spawn child process: C:/php/test.php

With url 404 Page Cannot be found
logs: Invalid URI /dev/test.php

Anyone has any ideas what is going wrong and if possible could you please recommend a solution.

Regards,
Sam
 
The problem is that Apache doesn't know which command-interpreter to use when running a PHP script.

This line:

Logs: C:/php/test.php is not executable; ensure interpreted scripts have "#!" first line

is the most interesting to me. It looks like Apache is expecting a unix-stype shebang line as the first line of the script.

A shebang line on unix-like OSes looks like this:

#! /usr/bin/php

and it describes where the OS can find the command interpreter appropriate for the script. You might try putting one in there, with the absolute path to your PHP interpreter.


Keep in mind, too, that CGI programs running under Apache are themselves responsble for their HTTP headers. If you don't at least output an appropriate "Content-type:" header, the script will likely fail.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
does anyone know how to get rid of #! completely for PHP? I used the #!/usr/bin/php where it was needed but when the program is including the executables anyway for info, you can see the #! as it's being displayed along with the HTML.

I've been working on this problem for three days and found no real solution. I have PHP 5.0.0 set-up and working.

---------------------------------------
If you helped... thx.
 
well it's in the apache httpd.conf under load something...
i'm new to apache so you must forgive me.

i don't exactly know, how can you find out?

---------------------------------------
If you helped... thx.
 
Generally, if you have a LoadModule directive which loads the PHP module, and if on startup Apache doesn't complain about not finding the modules's libary file, then PHP is running as a module, and the "#!" line is unnecessary.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
You should have an association to PHP in your apache conf file. Something like this

Code:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml

    <IfModule mod_php3.c>
        AddType application/x-httpd-php3 .php3
        AddType application/x-httpd-php3-source .phps
    </IfModule>

    <IfModule mod_php4.c>
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
    </IfModule>

For me that eliminates the need for the #! stuff in my php scripts.


 
taken care of thx. i re-installed apache with DSO support and things like that. i got it to work.

---------------------------------------
If you helped... thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top