I am having a problem with Php/Apache for Windows.

I have installed php and apache, and modified the Apache httpd.conf in the
ways followed:

<Directory "C:/Apache/cgi-bin">
Options ExecCGI
</Directory>
ScriptAlias /php/ "c:/Php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"

I then run the Apache server, and into a browser type
http://localhost/cgi-bin/test.php

The test.php file contains the text:
<?php echo "Hello"; ?>

The page that loads in the browser says: "The server encountered an internal
error or misconfiguration and was unable to complete your request".

And the error log says 2 things:
c:/apache/cgi-bin/test.php is not executable; ensure interpreted scripts
have "#!" first line
(2)No such file or directory: couldn't spawn child process:
c:/apache/cgi-bin/test.php

Can anyone help ????

    Have you modified php.ini-dist, then renamed it php.ini and placed it in c:\windows?

    Paul

      I noticed your script alias was:

      ScriptAlias /php/ "c:/Php/"

      Have you tried with?:

      ScriptAlias /php/ "c:/php/"

        James,

        You wrote:

        I have installed php and apache, and modified the Apache httpd.conf in the ways followed:

        <Directory "C:/Apache/cgi-bin">
        Options ExecCGI
        </Directory>

        and also:

        And the error log says 2 things:
        c:/apache/cgi-bin/test.php is not executable; ensure interpreted scripts have "#!" first line
        (2)No such file or directory: couldn't spawn child process: c:/apache/cgi-bin/test.php

        This indicates to me that Apache is trying to execute your php script as if it were a chi script, hence the prompt to have the shebang as the first line. While PHP typically runs as a cgi process on Win32, you do not need to place your php scripts in the cgi-bin. Try placing test.php in your document root, most likely c:/apache/htdocs if you haven't changed it, and see what happens. Assuming there is no problems with your php.ini, this should solve your problem. Hope this helps!!

        Cheers,

        Geoff A. Virgo

          2 months later

          I just went through a bunch of these postings and 90% of the people having problems have everything set up correctley in there httpd.conf. But they are missing one thing if you are getting the server configuration error make sure that you uncomment the line that enables the mod_mime module without this php will not work.

          Tim Holwig
          fabel@indirect.com

            Hey Tim,

            Good advice, but Apache Win32 does not use mod_mime for mime-types, rather it uses a file called mime.types which should be located in the apache\conf directory. The line which loads mime.types into Apache is:

            TypesConfig conf/mime.types

            so this is the line people should be making sure is uncommented. However, I believe it is uncommented by default at install time. The AddType directives which are required to set PHP up merely append mime-types to this file and can be removed from httpd.conf if you manually edit mime.types and add them there.

            Cheers,

            Geoff

              5 years later

              Hello,

              I also have the following in my error.log:

              [Wed Nov 02 14:09:00 2005] [error] [client 127.0.0.1] C:/Program Files/Apache Group/Apache2/htdocs/phpMyAdmin-2.6/index.php is not executable; ensure interpreted scripts have "#!" first line
              [Wed Nov 02 14:09:00 2005] [error] [client 127.0.0.1] (9)Bad file descriptor: don't know how to spawn child process: C:/Program Files/Apache Group/Apache2/htdocs/phpMyAdmin-2.6/index.php

              I removed the following ScriptAlias in my httpd.conf and now everything works:

              ScriptAlias /phpMyAdmin-2.6/ "C:/Program Files/Apache Group/Apache2/htdocs/phpMyAdmin-2.6/"

              <Directory "C:/Program Files/Apache Group/Apache2/htdocs/phpMyAdmin-2.6">
              AllowOverride None
              Options None
              Order allow,deny
              Allow from all
              </Directory>

              I obtained the above tip from the link below:

              http://www.modpython.org/pipermail/mod_python/2004-May/015537.html

              Of course, you must have installed the PHP module already (see PHP INSTALL.TXT). Also check your httpd error.log to see it has been loaded successfully.

              Regards,

                Write a Reply...