[FIX] Z-Push with lighttpd

Clarify issues about the installation

[FIX] Z-Push with lighttpd

Postby Xandrian » Mon Nov 05, 2007 9:21 am

Hi,

I am using Z-Push on a Webserver with Lighttpd and with no Apache. So PHP is not running as module. I am using the fast-cgi support from lighty. Here are my modifications:

lighttpd-func.php
Code: Select all
<?php
function apache_request_headers()
{
    $headers = array();

    foreach(array_keys($_SERVER) as $skey)
    {
        if(substr($skey, 0, 5) == "HTTP_")
        {
            $headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 0, 5)))));
            $headers[$headername] = $_SERVER[$skey];
        }
    }

    return $headers;
}
?>

The function "apache_request_headers" is only available if you are using an Apache with PHP as module. So I have to create an own function...

After you have created the file with the function you should include it on the top of the index.php-file
Code: Select all
include_once("lighttpd-func.php");

I included this line before the include of the config-file.

And at the end here's the rewrite rule
Code: Select all
  alias.url += (
    "/Microsoft-Server-ActiveSync" => "/var/www/z-push/index.php",
  )


Hava a lot of fun...

cu tb.
Xandrian
 
Posts: 5
Joined: Tue Oct 23, 2007 6:44 am

Re: [FIX] Z-Push with lighttpd

Postby Michael » Mon Nov 05, 2007 9:45 am

cool!

But you can also generate this function dynamicly in PHP when it doesn't exists.

Code: Select all
if (!function_exists("apache_request_headers")){
  function apache_request_headers()
  {
    // here your function
  }
}
Michael
 
Posts: 51
Joined: Mon Oct 08, 2007 8:10 am

Re: [FIX] Z-Push with lighttpd

Postby bas » Mon Nov 05, 2007 9:46 am

The function apache_request_headers should be added to compat.php.
compat.php is for implementing functions that are not available in all versions of php.
Just add the implementation posted in the following if statement:
Code: Select all
if (!function_exists("apache_request_headers")) {
bas
 
Posts: 75
Joined: Thu Oct 04, 2007 7:55 am
Location: NL: Brielle

Re: [FIX] Z-Push with lighttpd

Postby saz » Fri Jun 06, 2008 3:47 pm

Hi,

If you have a look at the description of apache_request_headers(), wouldn't it be enough to use $_ENV for accessing the needed values?

HAND,
Saz
saz
 
Posts: 1
Joined: Fri Jun 06, 2008 3:43 pm

Re: [FIX] Z-Push with lighttpd

Postby lanwin » Mon Sep 08, 2008 1:01 pm

Could please someone add this patch to Z-Push! With the patch z-push works fine on my lighttpd, but i dont want to patch z-push by hand every time.
lanwin
 
Posts: 5
Joined: Tue Jul 29, 2008 2:36 pm

Re: [FIX] Z-Push with lighttpd

Postby skummer » Mon Sep 08, 2008 2:07 pm

No, that will not be commited.
But you could easily add the code above to the end of your config.php. Then you don't have to patch your system at all (as the config file has to be changed/copied) anyway between the updates.

But anyway, the topic is "sticky" now.

Greetings, Sebastian
skummer
 
Posts: 589
Joined: Mon Sep 24, 2007 5:19 pm
Location: Belo Horizonte / Brasil

work with lighttpd (with .patch)

Postby glen » Tue Sep 09, 2008 7:48 pm

note that the code pasted above didn't work. so i fixed and improved it a little.

here's the code with test, you can compare running it under apache/lighttpd.

Code: Select all
<?
if (!function_exists("apache_request_headers")) {
    function apache_request_headers() {
        $headers = array();
        foreach ($_SERVER as $key => $value) {
            if (substr($key, 0, 5) != 'HTTP_') {
                continue;
            }
            $headername = strtr(ucwords(strtolower(strtr(substr($key, 5), '_', ' '))), ' ', '-');
            $headers[$headername] = $value;
        }

        return $headers;
    }
}
echo "<pre>";
print_r(apache_request_headers());
echo "</pre>";


or just download it: http://glen.alkohol.ee/pld/apache_reque ... rs.php.txt

also if z-push maintainers wish to include it, then here's it also in patch(1) format:
http://cvs.pld-linux.org/cgi-bin/cvsweb ... ders.patch
glen
 
Posts: 1
Joined: Tue Sep 09, 2008 7:43 pm

Re: [FIX] Z-Push with lighttpd

Postby grimble » Thu Dec 04, 2008 11:55 pm

skummer wrote:No, that will not be commited.


Hi,

I cannot understand your decision. This patch makes z-push compatible with every CGI supporting web serwer (apache, lighhtpd, nginx). I would even suggest removing apache_request_headers() function call because it's usefull only on Apache.

Could you please supply arguments that lead you to that decision?

regards,

Bartek
grimble
 
Posts: 1
Joined: Thu Dec 04, 2008 11:36 pm

Re: [FIX] Z-Push with lighttpd

Postby jens » Thu Jan 08, 2009 9:06 pm

Hi,

thanks for the fix ... I use lighttpd too and had the same problem.
Please include this in compat.php as suggested.

Brgds,
Jens
jens
 
Posts: 2
Joined: Thu Jan 08, 2009 9:04 pm

Re: [FIX] Z-Push with lighttpd

Postby maharaja » Tue Jan 20, 2009 7:11 pm

hi,

not this is not only an issue with lighttp but also with apache (!) using
  • suphp (means php-cgi)
  • fastcgi/fcgi (also php-cgi)
i would go the way to abandon the use of any sotware-specific method.

please provide reasons if you're not fixing this issue

cheers,
raoul
maharaja
 
Posts: 1
Joined: Tue Jan 20, 2009 6:36 pm

Next

Return to Installation

Who is online

Users browsing this forum: No registered users and 1 guest