# Lighttpd vs. nginx



## anigma (Mar 21, 2016)

Howdy. I'm currently thinking about moving from apache to either lighttpd or nginx in the near future. The reason for this is simple, I just need a lightweight HTTP server that can easily be configured (ie, setting up virtual hosts, user directories, directory listings and such). I also require PHP to be installed since I run a few applications based on PHP (postfixadmin, wordpress, roundcube). 

Are there any main reasons to go for one over the other considering my requirements?

I have read a great deal lighttpd vs nginx articles, but none really describe in detail appropriate uses for the two HTTP servers. If you guys know of such articles or reviews, I'd appreciate if you point me to them.


----------



## drhowarddrfine (Mar 21, 2016)

It's been a while but I always struggled getting anything to work with lighty. I also have the impression that its universe is much smaller than all the others but anyone could prove me wrong. nginx always worked for me from the first time I used it and there seems to be far more information out there. Until just recently, all development was done on  FreeBSD, too, but for technical reasons, I don't have any answers.


----------



## SirDice (Mar 22, 2016)

I would suggest sticking to Apache. Although nginx is a fine web server, it's really meant to serve static pages. You can configure nginx to use PHP but setting up more than one PHP application on the same server is a royal PITA to get working and still keep things secure. In this respect Apache is a lot simpler and safer to configure.


----------



## uzsolt (Mar 23, 2016)

I'm not professional but I think `nginx`'s configuration is simple - if you understand it 
One thing: on `nginx` (and as I see on `lighttpd` too) can't use .htaccess - they don't support it (see here).


----------



## SirDice (Mar 23, 2016)

uzsolt said:


> I'm not professional but I think `nginx`'s configuration is simple - if you understand it


It is simple. If you stick to one PHP site. However, its simplicity is going to ruin your day if you attempt to run multiple PHP applications on the same site. Most examples you find on the internet are about as secure as an open door.

https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/


----------



## uzsolt (Mar 23, 2016)

Off: SirDice as I said I'm not professional (and my english isn't professional too) so I don't understand you exactly. Can you post a simple example please?


----------



## gkontos (Mar 23, 2016)

From a professional point of view, there is a misconception that Nginx is faster and safer than Apache. This gives a false perception that you are running a faster and more secure web server.


----------



## SirDice (Mar 24, 2016)

uzsolt said:


> Can you post a simple example please?


No, I don't have any _simple_ examples. That's more or less the point I was trying to make. Configuring nginx may look simple but it usually isn't. Some time ago I spent several days trying to get two PHP applications to behave nicely together on the same server. I either ended up with a working configuration that was insecure or a secure configuration that didn't work. In the end I just gave up, installed Apache and had a working, secure, configuration in a few minutes. What I'm trying to say is, don't be fooled by the apparent simplicity of the configuration.


----------



## uzsolt (Mar 24, 2016)

Ah, understand now 
Many people say that `nginx` configuration is difficult and `apache` configuration is simpler. I think most people use `apache` and know it well. I'm using `nginx` and after the some first difficult things I like it and now it isn't difficult for me


----------



## Jeckt (Mar 24, 2016)

You're right about those familiar with Apache advocating it's simplicity. What in the hell is with those pseudo html style tags in the configuration anyway? I think a big part of Apache's problem is default installs have a TON of unneeded crap which clutter the config file substantially. When you cut out unneeded junk, it's not half as bad. If you keep it simple, Nginx is very simple at first. The way it's architecture works using hash tables for performance, it can get hairy.

I used lighttpd years back, but got away from it. It seems like development has stagnated (not interest in http2 for instance), and it never worked quite right (maybe just on FreeBSD?). If using PHP-FPM you'll probably find Nginx fairly simple. If not, Apache will likely be easier. I'd still give nginx a shot, I've been pretty happy with it - mind you I still use Apache for some things too, sometimes together with Nginx.


----------



## drhowarddrfine (Mar 24, 2016)

Some additional notes from my usage.

I originally started using nginx because it meant I could run it on smaller servers and configuration was definitely easier and nginx is definitely faster. However, nothing I do is highly complex and Apache made changes, since I started, that makes it competitive with nginx in speed. Apache loaded lots of things I would never use though they can be removed. nginx adds nothing extra unless you ask for it. I could find myself back on Apache if things started getting complicated but ...

It's been a while since I've bothered to look at things so take what I said with a grain of salt.


----------



## diizzy (Mar 31, 2016)

nginx will do just fine and as other have mentioned and will probably give you a better overall overview. You can however do bad/stupid things using both nginx and Apache so I don't think that's a valid point for either side. nginx also has a slight advantage if you're low on resources.

That said, I've found some PHP applications that I never got to work using nginx. Mostly because debugging (logging) is painfully bad between nginx and PHP.
//Danne


----------

