lighttpd instead of Apache?

Hi,

I was just wondering if anyone has considered using / is using lighttpd (http://www.lighttpd.net/) instead of Apache.

Lighttpd seems to be designed to take up a small amount of memory - one of the areas in which linodes are limited.

If you are using it, what are your experiences? Does it take up less memory than apache? Is it stable? Is it hard to configure?

Thanks :)

15 Replies

I use thttpd (http://www.acme.com/software/thttpd) which is absolutely tiny. It has less functionality than lighttpd but if you just want a basic web server with simple CGI support then you can't get much smaller than thttpd :-) I currently have it configured for 3 virtual servers and "ps" shows it has a VSZ of 2212, with an RSS of 652. That's tiny :-)

No fast CGI, not much in the way of functionality at all. But for a basic web server, it does the job :-)

Can it support PHP with all it's extensions? and virtual hosts?

Well, much as it's not recommended by the PHP team, you can run PHP through the CGI interface, so yes, thttpd could support it if set up properly.

As for virtual hosts, I believe he already mentioned that he had 3 running. :D

I'm about to give lighttpd a try myself. Looks like the folks over at textdrive love it. Especially check out the benchmarking post.

@hallow:

I'm about to give lighttpd a try myself. Looks like the folks over at textdrive love it. Especially check out the benchmarking post.

Well, I've gotten it up and running (http://webmages.com/). I'm using an externally spawned php fastcgi server, with two instances of lighttpd running (one ssl, one not) sharing the same php instance. Php also has eAccelerator installed. I've got rewrite rules setup and working with my wordpress installation, although I haven't gotten rules working with my gallery2 install, so for now no permalinks there, but otherwise it works.

I'm doing the exact same.

http://xen.oldos.org <– running on my xen beta linode, gentoo 2005.0, lighttpd+php-fcgi+mysql 4.0

http://v7forum.oldos.org <-- running on my main UML linode, debian sarge, apache2+mod_php+mysql 4.1

Any one know what lighttpd is like for perl scripts and ssl?

Adam

@adamgent:

Any one know what lighttpd is like for perl scripts and ssl?

Adam

You have to run a separate process for ssl.

Perl scripts have to be run as a cgi or fcgi.

Have you played around with remote servers running fastcgi (lighthttpd on one box, php on another)? Does the other box need to have it's own copy of the website?

If not, maybe whoevers doing the hosted mysql service could offer a hosted php service. :)

@Jay:

@adamgent:

Any one know what lighttpd is like for perl scripts and ssl?

Adam

You have to run a separate process for ssl.

Perl scripts have to be run as a cgi or fcgi.

But don't be too concerned about the seprate process thing. They can share the same backend (both of mine use the same PHP), so the total ram useage increase is about 600k (which is about 1/2 of what the first process uses for me).

PHP is kind of a hog (uses about 48m between all the processes here), I'm sure perl is too. Maybe after after lighttp dev starts to slow down we can get them to work on a new scripting language. :)

Just wanted to chime in. I am using lighttpd for Rails and FastCGI, couldn't be happier at the moment.

Combined with SQLite and I'm a happy camper with my UML Linode 80.

Only comment: lighttpd looks nice. I've got a friend on OpenBSD running it.

The only oddity is when he runs it with IPv6 enabled, all v6-based requests that hits lighttpd is returned up to precisely 16K worth of data before lighttpd closes the connection.

No obvious config file or code issue. He can get > 16K with any other v6-based apps, so don't think the issue is with his TCP stack.

Just FYI, in case you need to run lighttpd with IPv6; test!

Other than that, looks to be pretty good.

If you use scripting, beware that Lighttpd's default dir for fastcgi scripts can change with each restart. This means if you don't explicitely set the current dir within your scripts, it may break at unexpected times.

For example, the following will make the default dir for fastcgi scripts to be /

cd /
/etc/init.d/lighttpd restart

And the following will make the default dir for fastcgi scripts to be /usr/bin:

cd /usr/bin
/etc/init.d/lighttpd restart

Whether this is a serious security flaw or merely a compatibility annoyance with scripts that run fine in Apache can be debated elsewhere. But knowing about it helps avoid issues.

Just wondered if anyone had tried lighttpd with virtual hosts and url-rewriting?

The vhosts system looks like it might make more sense if you're literally hosting sites as:

* /websites/example1.com

  • /websites/example2.com

  • /websites/example3.com

But if you wanted to do anything more exotic, you'd need to write lots of rewrite rules, by the looks of things. Anyone tried this at all? Is it faster than the equivalent Apache setup? (I should imagine if you're using 'simple vhosts' like above, it would in all probability be faster)

Also, it's not overly clear from the lighttpd website whether URL rewriting is specified in the main configuration file, or whether it can be set per-directory like in Apache's .htaccess files. If not, that could be quite a limitation which would put me - and probably others - off.

It seems that lighttpd might work better for what I want than Apache might, but I'm not yet sure.

Has anyone here tried this?

@Arantor:

Just wondered if anyone had tried lighttpd with virtual hosts and url-rewriting?

snip

It seems that lighttpd might work better for what I want than Apache might, but I'm not yet sure.

Has anyone here tried this?

I've been running lighttpd for a few months now, using URL Rewriting to get decent URLs from Gallery. I'm doing vhosting via the HOST variable. For example:

$HTTP["host"] == "www.moregruel.net" {
        server.document-root = "/var/www/wordpress"
        alias.url = ("/gallery/" => "/usr/share/gallery/", "/gallery" => "/usr/share/gallery", "/albums" => "/var/www/albums")

        url.rewrite = ( 
        "^/gallery/([^\.\?/]+)/([0-9]+)$" =>
                "/gallery/view_photo.php?set_albumName=$1&index=$2",
        "^/gallery/([^\.\?/]+)/([A-Za-z_0-9\-]+)$" =>
                "/gallery/view_photo.php?set_albumName=$1&id=$2",

*and so on*

So rewriting is not per-directory via .htaccess, but since you pattern match, you can make it per-directory. It's considerably faster overall than apache 1 on my machine, mostly due to lower memory use. Whether this would meet your needs is up to you.

Steve

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct