litespeed, fastcgi apache incompatibility

accassar

Active Member
#1
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
 

NiteWave

Administrator
#2
just list the difference from your post to be more clear:
~>diff apache lsws
1,6c1,6
< PATH_INFO /index.php/category/library
< PATH_TRANSLATED /my/document/root/index.php/category/library
< REDIRECT_URL /index.php/category/library
< SCRIPT_FILENAME /bin/php5 <- from apache config
< SCRIPT_NAME /fcgi-bin/php5ac <- from apache config
< SERVER_SOFTWARE Apache
---
> PATH_INFO /category/library
> PATH_TRANSLATED /my/document/root/category/library
> QUERY_STRING
> SCRIPT_FILENAME /my/document/root
> SCRIPT_NAME /index.php/category/library
> SERVER_SOFTWARE LiteSpeed
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.
 

accassar

Active Member
#3
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.








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.
 

webizen

Well-Known Member
#6
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.
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.

Apache
--------
PATH_INFO:/category/library
PATH_TRANSLATED:/path/to/php-fcgi/index.php
SCRIPT_FILENAME:/path/to/php-fcgi/index.php

LSWS
------
PATH_INFO:/category/library
PATH_TRANSLATED:/path/to/php-fcgi/category/library
SCRIPT_FILENAME:/path/to/php-fcgi/index.php
Maybe you can pm your setup to help reproduce that?
 
Top