litespeed, fastcgi apache incompatibility

Discussion in 'Install/Configuration' started by accassar, May 3, 2012.

  1. accassar

    accassar New Member

    Hi Guys,

    I've found the reason for the rewrite issues with litespeed and PHP running under fastcgi.

    The issue is that fastcgi sends different variables over the fastcgi connection then apache - which results in PHP not interpreting PATH_INFO correctly.

    If you compare the output from the fastcgi variables below, especially the path_translated and path_info as that is what the PHP fastcgi handlers care about, you will see the obvious error. All the complaints on the forums about PHP saying 'file not found' for this style of URL can be explained in the differences below.

    Is there any chance if LSWS being updated? I don't really want to change the fastcgi code in PHP to work with LSWS if I can help it, and I haven't checked if LSAPI works correctly or not - but for this particular use case (and I imagine many others where there is a migration from webserverX -> litespeed) this is the best option forward.

    FastCGI request from Apache:

    SERVER_SOFTWAREApache
    SERVER_NAMEtest.com
    SERVER_ADDR1.2.3.4
    SERVER_PORT80
    REMOTE_ADDR1.2.3.4
    DOCUMENT_ROOT/my/document/root
    SERVER_ADMINtest@test.com
    SCRIPT_FILENAME/bin/php5 <- from apache config
    REMOTE_PORT53960
    REDIRECT_URL/index.php/category/library
    GATEWAY_INTERFACECGI/1.1
    SERVER_PROTOCOLHTTP/1.1
    REQUEST_METHODGET
    REQUEST_URI/category/library
    SCRIPT_NAME/fcgi-bin/php5ac <- from apache config
    PATH_INFO/index.php/category/library
    PATH_TRANSLATED/my/document/root/index.php/category/library

    Request method from LSWS:

    GATEWAY_INTERFACECGI/1.1
    SERVER_SOFTWARELiteSpeed
    SERVER_PROTOCOLHTTP/1.1
    REQUEST_METHODGET
    SCRIPT_FILENAME/my/document/root
    QUERY_STRING
    SCRIPT_NAME/index.php/category/library
    DOCUMENT_ROOT/my/document/root
    REMOTE_ADDR1.2.3.4
    REMOTE_PORT50424
    SERVER_ADDR1.2.3.4
    SERVER_NAMEtest.com
    SERVER_ADMIN
    SERVER_PORT8088
    REQUEST_URI/category/library
    PATH_TRANSLATED/my/document/root/category/library
    PATH_INFO/category/library
  2. NiteWave

    NiteWave Administrator

    just list the difference from your post to be more clear:
    if able to covert to LSAPI php, that'll be better. since lsphp can be regarded as optimized fast cgi and best performance in corporation with litespeed web server.
  3. accassar

    accassar New Member

    I can't convert from FastCGI to LSPHP at this stage while we do the migration.

    PATH_INFO/index.php/category/library <- apache
    PATH_INFO/category/library <- LSW

    PATH_TRANSLATED/my/document/root/index.php/category/library <- apache
    PATH_TRANSLATED/my/document/root/category/library <- LSW

    From the above which I obtained via tcpdump, you can see that LSW does not pass the PHP file through to the fastcgi runner in either the PATH_INFO or PATH_TRANSLATED variables. The PHP fastcgi runner cannot find the php file in question, hence the error about not finding the file.

    I believe if you can resolve this issue, this will improve compatibility with apache when migrating client sites. In my original thread it required changing the clients rewrite rule, however if the correct FASTCGI variables are passed to PHP - no change will be required.








  4. accassar

    accassar New Member

    Any feedback?
  5. accassar

    accassar New Member

    The problem is not the build, the problem is the way that lsws is passing the fastcgi variables. This is why PATH_INFO does not with with PHP and fastcgi. Please read the previous posts.

  6. webizen

    webizen New Member

    That's why the post was removed already.

    We tested in our lab run php with fcgi support under both Apache and LSWS. It shows that Apache and LSWS have the same path info but different path_translated (index.php removed in LSWS path_translated as you pointed out). however, script_filename is the same as path_translated in Apache which is different from your result.

    Maybe you can pm your setup to help reproduce that?
  7. accassar

    accassar New Member

    I think I've sent you a pm with the details. Let me know if it's not received.

Share This Page