OpenWrt Forum Archive

Topic: webif in lighttpd ??

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

What is the proper way to setup webif to run in lighttpd?

in my lighttpd.conf i added

cgi.assign = ( ".php" => "/bin/php", ".sh" => "" )


webif does not display the values and lighttpd logs an error messager

/bin/sh: nvram: not found



any ideas?  thanks in advance

You should assign the .sh scripts to haserl 
Something like (not sure about syntax, but I use your example above) :

cgi.assign = ( ".php" => "/bin/php", ".sh" => "haserl" )

yeah when i do that nothing shows up... i get   <@TR>  all over the page

ok i figured it out...  the syntax i had above was correct, however i also had the .sh extension included in this line below:

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".sh" )

The .sh SHOULD NOT be in there... i dunno why i thought it belonged there, but it does not.  Then

cgi.assign = ( ".php" => "/bin/php", ".sh" => "" )

will allow webif to run under lighttpd

I've tried doing what you say (and many other things) and still cannot make it work. It "looks like" working, but whenever I want to change some configuration through the web interface I just get errors and nothing changes. And using haserl, as someone suggested, I get <@TR> all over, as you said.

The only explanation that comes into my mind is that it doesn't have root privileges, and therefore cannot change anything, but I can't find how to change this.

Any ideas??

Thanks

i dunno what happened but... it broke again... so now i continue to log the /bin/sh nvram not found... anyone come up w/ anything new on this?

It's working now!! big_smile

How? I just upgraded the whole system and it started working (after some hours fighting with my dnsmasq and wireless, that were totally screwed up by the upgrading, but that's another story).

The problem now is that it asks me for a root password every time I try to access any webpage in the server, but I didn't have time yet to look into it, so I don't know how easy or dificult is the solution.

when you say the whole system... you mean the lighttpd daemon?  or just wiped everything out w/ a new flash

Is this works with fastcgi or only with cgi?

To get the nvram command to work in my setup I had to ipkg install lighttpd-mod-setenv, then enable mod_setenv in server.modules and add
setenv.add-environment = ("PATH" => "/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin")
To lighthtpd.conf.

Note to get the scripts to execute I added this to my lighttpd.conf

cgi.assign = (".sh" => "/usr/bin/webif-page")

The only thing I am still struggling with is to get the graphs displaying, they used to work in firefox (on Mac) but stopped working on a recent update.

My browser only gives me the option of saving the .svg binary file. I'm wondering if there's a mime type problem for this one.

Sorry for not answering before. I've been very busy with other things lately.

But my last post was actually not true. When I upgraded the system to RC6 lighttpd (together with many other things) just stopped working, and the old httpd came back. That's why webif was working again, but I didn't realize that it was not under lighttpd until a couple of days ago.

Now, with the solution of langdt it's working under lighttpd again. I also have problems with the graphs, and I'm using firefox. Please tell me if you find some solution.

Thank you langdt!!

Hello,
I tried to switch to lighttpd but I have problems with executing the scripts correctly. Lighttd always tried to download the files. I tried all the above mentioned configuration for lighttpd.conf but none of them works.

In the error log file I have :

(server.c.931) WARNING: unknown config-key: cgi.assign (ignored)

when I add .sh in the cgi.assign option.

edit: when I DO add

# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" , ".sh" )

It seems that the sh file is being executed but I get a "403 - Forbidden" error.

Regards,
Tex

(Last edited by Tex-Twil on 30 Mar 2008, 09:55)

I found something new. When I try to start the server I have this error :

root@ap:~# /etc/init.d/lighttpd start
2008-03-30 12:51:53: (plugin.c.165) dlopen() failed for: /usr/lib/lighttpd/mod_cgi.so File not found
2008-03-30 12:51:53: (server.c.621) loading plugins finally failed

The shared object for cgi is NOT present in the installation:

root@ap:~# ll /usr/lib/lighttpd/
-rwxr-xr-x    1 root     root        15322 Mar 30 07:35 mod_dirlisting.so
-rwxr-xr-x    1 root     root         5298 Mar 30 07:35 mod_indexfile.so
-rwxr-xr-x    1 root     root         9406 Mar 30 07:35 mod_staticfile.so

I unpacked the package lighttpd_1.4.19-2_mipsel.ipk  file and it is not there either. I will try to compile this module and install it. I'll let you know.

any ideas ?

Tex

(Last edited by Tex-Twil on 30 Mar 2008, 14:00)

Ok, installing the     lighttpd-mod-cgi worked. So to sum up, the changes in  /etc/lighttpd.conf are:

server.modules = ( 
    "mod_cgi"
)
...
#### CGI module
cgi.assign = ( ".pl"  => "/usr/bin/perl", ".cgi" => "/usr/bin/perl", ".sh" => "/usr/bin/webif-page" )

# Here both putting  or omitting ".sh" works ...

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi"  )

Tex.

(Last edited by Tex-Twil on 30 Mar 2008, 14:14)

How can I assign .sh scripts to haserl if I'm running php-fastcgi on lighttpd?

Tex-Twil wrote:

Ok, installing the     lighttpd-mod-cgi worked. So to sum up, the changes in  /etc/lighttpd.conf are:

server.modules = ( 
    "mod_cgi"
)
...
#### CGI module
cgi.assign = ( ".pl"  => "/usr/bin/perl", ".cgi" => "/usr/bin/perl", ".sh" => "/usr/bin/webif-page" )

# Here both putting  or omitting ".sh" works ...

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi"  )

Tex.

This solution indeed works! Very nice.

Also found a solution to protect the webif pages (which aren't protected by using the above config).

auth.debug = 2
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/.htpasswd"

$HTTP["url"] =~ "/webif/" {
    auth.require = ( "" =>
        (
            "method"  => "digest",
            "realm"   => "Passworded Area",
            "require" => "valid-user"
        )
    )
}

Only thing you need to do is create a .htpasswd using htdigest.

(Last edited by pdrai on 25 Aug 2010, 11:02)

The discussion might have continued from here.