an error with iis 7.5 - fastcgi and php 5.2.13 [Answered]RSS

12 replies

Last post Apr 13, 2010 05:50 PM by don.raman

  • an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 01:49 PM|pvo01|LINK

    I am running w2k8 r2 and iis7.5

    <?php

    phpinfo();

    ?> 

    works.

    however, when I am browsing other .php files it give me this error.

     HTTP Error 502.2 - Bad Gateway
    The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "<b>Security Alert!</b> The PHP CGI cannot be accessed directly. <p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.</p> <p>For more information as to <i>why</i> this behaviour exists, see the <a href="http://php.net/security.cgi-bin">manual page for CGI security</a>.</p> <p>For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit <a href="http://php.net/install.windows">the manual page</a>.</p>".

     

    ***

     Note that, all other .htm and xml works fine.

     This is a clean install.

    I download the non-thread-safe 5.2.13 and uzip it to c:\php

    I changed the php.ini-recommend to php.ini

    I added to *.php and point it to c:\php\php-cgi.exe and fastCGIModules in the HandlerMapping.

    I tried enable 32 bit app in the applicaion pools.

     Please give me some light if anyone know a fix to this.

     

    PS. i was using this http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-7/ as instructions

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 02:01 PM|don.raman|LINK

    Hi,

    Seems like you are not using the right binaries. Two alternatives:

    1. Undo whatever you have done and use Microsoft Web Platform Installer to install PHP. Details at http://blogs.iis.net/donraman/archive/2009/10/07/installing-php-on-windows.aspx.

    2. DId you install the VC9 binaries of PHP 5.2.13? If not switch to that as VC6 binaries are meant for Apache.

    I would recommend do as specified in solution 1.

    Let me know how it goes.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 02:23 PM|pvo01|LINK

    Hello Don,

    1.

    Just to make sure that i downloaded the right file

    http://www.php.net/downloads.php

     PHP 5.2.13 Non-thread-safe zip package [10,185Kb] - 25 February 2010
    md5: a7bd052e7a1413b743c07ae37171980d

    above is the file that I downloaded.

     

    2.

    I like your WPI because it will for sure save me a lot of time and errors; but howerver I still like to do a manual setup.

    I have done earlier verson of php with ASPI and it works great. I reacently heard that FastCGI is much improve over CGI so I dicided to try out FastCGI .

    Also, I have not yet tried WPI but I can see that you say it only come with php 5.2.11. How about have it so one can choose which version of php they want?

     

    3.

    To be honest, I don't know what are VC9 and VC6.  I am a noob at php, I forgot to tell.

     

    Thanks for any input.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 03:52 PM|don.raman|LINK

    pvo01

    http://www.php.net/downloads.php

     PHP 5.2.13 Non-thread-safe zip package [10,185Kb] - 25 February 2010
    md5: a7bd052e7a1413b743c07ae37171980d

    Can you try downloading the files from http://windows.php.net/downloads/releases/php-5.2.13-nts-Win32-VC6-x86.zip. The download are available at http://windows.php.net/download/ and sha1: 2095247c0716819feeddae4b544c62f544dc82b6 .

    pvo01

    Also, I have not yet tried WPI but I can see that you say it only come with php 5.2.11. How about have it so one can choose which version of php they want?

    No, WPI provides you the latest PHP 5.2.13. You must have an old feed. And trust me WPI will do exactly the same thing but in a more elegant way.

    pvo01

    To be honest, I don't know what are VC9 and VC6.  I am a noob at php, I forgot to tell.

    Sorry, since you are using 5.2.13 it only has VC6 build. VC6 and VC9 options are available only from PHP5.3 onwards. VC^ used old VIsual Studio compiler whereas VC9 uses the new Visual Studio 2008 compiler.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 04:27 PM|pvo01|LINK

     After a few tests,

    It comes to my attention that if I change the php.ini-recommended to php.ini, restart the web services, then the .php site/files will stop working immediately.

    However, if I were to rename it back to php.ini-recommended, and restart the web services, then it will work again.

     Any ideas?

     

    I think I need to have the php.ini because I need to do some modification to it to enhance the security, but if this doesn't allow me to rename it so, I am totally confuse now.

    Please show me some light.

     Thanks.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 05:24 PM|don.raman|LINK

    This is all the reason to use Microsoft Web Platform Installer. Otherwise it is difficult to know which line in php.ini is creating this problem. You will need to start commentinng/deleting few lines and see which line or set of lines are creating problems.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 12, 2010 05:28 PM|don.raman|LINK

    Alternatively you can start adding things to correct php.ini which you need and which is working and see if it works still.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 10:06 AM|pvo01|LINK

     

    don.raman

    2. DId you install the VC9 binaries of PHP 5.2.13? If not switch to that as VC6 binaries are meant for Apache.

     Hello Don,

    Do you recommend using VC6 or VC9? (I think I am gonna use 5.3.2 if 5.2.13 keep giving me problems)

    Because, you were right, 5.1.13 only comes with VC6.

    Btw, I am using w2k8 r2 64 bit platform. 

    Thanks.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 01:22 PM|don.raman|LINK

    Can you please try using WPI for once. If you are palnning to move to PHP 5.3.2 use VC9 build. And remember PHP 5.3.2 has it's own set of big problems.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 03:43 PM|pvo01|LINK

     Don,

     I used the WPI and it works.

    Howerver,

    I used the PHP.ini that came installed in the Program Files (x86) I can see that there are a few differences between it and the php.ini-recommended (which I will need to rename it to php.ini) of the 5.2.13 version.

    Here are the different.

    ****

    - off the WPI

    max_execution_time =300
    extension_dir ="C:\Program Files (x86)\PHP\ext"

    *some extra lines that the php.ini-recommended doesn't have
    upload_tmp_dir="C:\Windows\Temp"
    session.save_path="C:\Windows\Temp"
    error_log="C:\Windows\temp\php-errors.log"
    cgi.force_redirect=0
    fastcgi.impersonate=1
    fastcgi.logging=0


    *and some more extra


    [PHP_CURL]
    extension=php_curl.dll
    [PHP_GD2]
    extension=php_gd2.dll
    [PHP_GETTEXT]
    extension=php_gettext.dll
    [PHP_IMAP]
    extension=php_imap.dll
    [PHP_MBSTRING]
    extension=php_mbstring.dll
    [PHP_MSSQL]
    extension=php_mssql.dll
    [PHP_MYSQL]
    extension=php_mysql.dll
    [PHP_MYSQLI]
    extension=php_mysqli.dll
    [PHP_OPENSSL]
    extension=php_openssl.dll
    [PHP_PDO]
    extension=php_pdo.dll
    [PHP_PDO_MYSQL]
    extension=php_pdo_mysql.dll
    [PHP_PDO_SQLITE]
    extension=php_pdo_sqlite.dll
    [PHP_SOAP]
    extension=php_soap.dll
    [PHP_TIDY]
    extension=php_tidy.dll
    [PHP_XMLRPC]
    extension=php_xmlrpc.dll
    [PHP_ZIP]
    extension=php_zip.dll
    [PHP_EXIF]
    extension=php_exif.dll


    - of the phi.ini-recommended

    max_execution_time =30
    extension_dir ="C:PHP\ext"

     

    ****

     

    Ok, despite all that differences, but it all comes to just one line that really cause the whole problem.

    That is, if I just to only add this line

    fastcgi.logging=0 

    to the php.ini-recommended and rename it to php.ini then my php sites will work.

    (note that I only added that line, but nothing else.)

     I found that weir,  and I hope someone can point to me why that cause the problem.

    Thank you for your input.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 04:29 PM|don.raman|LINK

    Hi,

    pvo01

    I used the WPI and it works.

    Thanks and glad to know that your PHP is working.

    pvo01

    Here are the different.

    ****

    - off the WPI

    max_execution_time =300
    extension_dir ="C:\Program Files (x86)\PHP\ext"

    *some extra lines that the php.ini-recommended doesn't have
    upload_tmp_dir="C:\Windows\Temp"
    session.save_path="C:\Windows\Temp"
    error_log="C:\Windows\temp\php-errors.log"
    cgi.force_redirect=0
    fastcgi.impersonate=1
    fastcgi.logging=0

    These are all recommended settins for running PHP on IIS using IIS FastCGI. They are extremely important not only from functionality point of view but also from security perspective. You can find reasoning behind them and details at http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-7/. We increased the max_execution_time as some application like SugarCRM, drupal takes a longer time to install and we do not want people running into time out problem while installing these popular applications. Please keep them as it is if possible.

    pvo01

    [PHP_CURL]
    extension=php_curl.dll
    [PHP_GD2]
    extension=php_gd2.dll
    [PHP_GETTEXT]
    extension=php_gettext.dll

    And more extnesion, I will see it is based on your need. If you do not want an extension loaded simply comment it. However most of the popular application may need it and hence we have kept it by default. Example, GD2 is an extremely popular extension if you are using images in your application. But feel free to comment in if you think it is not required.

    pvo01

    Ok, despite all that differences, but it all comes to just one line that really cause the whole problem.

    That is, if I just to only add this line

    fastcgi.logging=0 

    to the php.ini-recommended and rename it to php.ini then my php sites will work.

    IIS FastCGI module will fail the request when PHP sends any data on stderr by using FastCGI protocol. Disabling FastCGI logging will prevent PHP from sending error information over stderr, and generating 500 response codes for the client. Look at http://forums.iis.net/t/1160323.aspx for some more clarity.

    Thanks,

    Don.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 04:44 PM|pvo01|LINK

     Don,

    That was exactly the error I was getting, namely, the "500 internal server error". 

    Also, this box is gonna be a production box, but, it will just only for our internal use, and not external use, also we are not hosting any major application on this box too, so I am guessing that many of the extension/.dll are not neccessary.

    And, thanks for your clarification.

  • Re: an error with iis 7.5 - fastcgi and php 5.2.13

    Apr 13, 2010 05:50 PM|don.raman|LINK

    Yes, feel free to disable the extension that is not required. It will save some time too while processing request.

    Thanks,

    Don.