Long story short I installed LiteSpeed Web Server on one of my boxes for testing, evaluation, and benchmarking purposes. Some of my tests use a Drupal installation installed here: $DOC_ROOT/drupal.
The used rewrite rule is pretty straightforward:
At least this is what I though, but for 15 minutes I felt like a complete moron that isn't able to write a simple rewrite rule. Wait, actually the rewrite rule is fine, as the server log says: drupal/node/1 goes to drupal/index.php?q=node/1. Placing a small debug script that replaces Drupal's front controller confirms that $_GET['q']/$_REQUEST['q'] is indeed node/1. However, all the static content throws 404 errors. All the paths to the static content are brokenly generated by Drupal.
Instead of:
I got:
Since none of my previous setups have this issue, the reason was pretty obvious: the web server isn't setting properly some parameters that PHP receives. Educated guess: $_SERVER.
Instead of $_SERVER['SCRIPT_NAME'] = '/drupal/index.php' and $_SERVER['PHP_SELF'] = '/drupal/index.php', LSWS + Rewrite + PHP LSAPI insist on $_SERVER['SCRIPT_NAME'] = '/drupal/node/1'; and $_SERVER['PHP_SELF'] = '/drupal/node/1';. Actually the SCRIPT_NAME is the piece that actually breaks Drupal.
I could "fix" it with some ini settings wizardry (auto_prepend_file) which executes this script for every PHP request:
Configuration:
Ubuntu Server 10.04 LTS amd64
LiteSpeed Web Server 4.0.14 Standard (x86 + Ubuntu's ia32-libs)
PHP 5.3.2/Zend Server 5.0.1 + PHP LSAPI 5.3.1
Just to be clear (if you actually "try this at home"): Zend Server/Zend Server CE includes a source package that contains PHP patches not available into the upstream PHP 5.3.2 as Zend says. Creating a binary compatible SAPI (including LSAPI) is a trivial task (if you manually pick all the dependencies, not too many), but the Zend extensions (Data Cache, Optimizer+) may or may not work. Data Cache works only with mod_php (software switch, had some rough discussions with the Zend guys about the lack of support for FastCGI), while Optimizer+ doesn't work beyond mod_php, FastCGI. This obviously shouldn't break LSAPI in any way as the $_SERVER superglobal is set by the web server.
Later edit: the other PHP hog, besides Drupal (great for benchmarking), called Joomla also suffers because of this specific behavior of the web server.
The used rewrite rule is pretty straightforward:
RewriteCond %{REQUEST_URI} ^/drupal
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/drupal/(.+)$ /drupal/index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/drupal/(.+)$ /drupal/index.php?q=$1 [L,QSA]
Instead of:
drupal/modules/node/node.css?3
drupal/node/modules/node/node.css?3
Instead of $_SERVER['SCRIPT_NAME'] = '/drupal/index.php' and $_SERVER['PHP_SELF'] = '/drupal/index.php', LSWS + Rewrite + PHP LSAPI insist on $_SERVER['SCRIPT_NAME'] = '/drupal/node/1'; and $_SERVER['PHP_SELF'] = '/drupal/node/1';. Actually the SCRIPT_NAME is the piece that actually breaks Drupal.
I could "fix" it with some ini settings wizardry (auto_prepend_file) which executes this script for every PHP request:
<?php
$proper_var = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']);
$_SERVER['PHP_SELF'] = $proper_var;
$_SERVER['SCRIPT_NAME'] = $proper_var;
$proper_var = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']);
$_SERVER['PHP_SELF'] = $proper_var;
$_SERVER['SCRIPT_NAME'] = $proper_var;
Ubuntu Server 10.04 LTS amd64
LiteSpeed Web Server 4.0.14 Standard (x86 + Ubuntu's ia32-libs)
PHP 5.3.2/Zend Server 5.0.1 + PHP LSAPI 5.3.1
Just to be clear (if you actually "try this at home"): Zend Server/Zend Server CE includes a source package that contains PHP patches not available into the upstream PHP 5.3.2 as Zend says. Creating a binary compatible SAPI (including LSAPI) is a trivial task (if you manually pick all the dependencies, not too many), but the Zend extensions (Data Cache, Optimizer+) may or may not work. Data Cache works only with mod_php (software switch, had some rough discussions with the Zend guys about the lack of support for FastCGI), while Optimizer+ doesn't work beyond mod_php, FastCGI. This obviously shouldn't break LSAPI in any way as the $_SERVER superglobal is set by the web server.
Later edit: the other PHP hog, besides Drupal (great for benchmarking), called Joomla also suffers because of this specific behavior of the web server.
Last edited: