I have a small module, running Linux, that I’m needing to install a web server on. I’m going to be using just PHP and HTML. Does anyone have any recommendations on what to use? Thanks!
If you’re using php, I would suggest that you stick with Apache. If resources are scarce, you can disable some of the default modules that Apache comes with. Alternatives requires you to run php as cgi.
good to know. we’re using apache on other modules and it’s been fine. just checking for any alternatives. you know how quick technology changes.
You may want to give Lighttpd a chance. We’ve been using it for a while in production. It’s lightweight and easy to manage, but isn’t fully compatible (for example, it doesn’t support .htaccess files so you have to rewrite the URL rewrites). As kyber mentioned, you have to run PHP as FastCGI (php-fpm, included in recent versions of PHP), but this isn’t at all a big issue, and works very fine. Apart from very specific things (svn server, intranet sites that require a client certificate), lighty is an excellent alternative and we’re porting all of our webservers to it.
All this is being said for nginx, too, but apart from a few tries, I have no experience with it.
Apache is neither light no robust. I recommend lighttpd with php as fastcgi.
nginx has some awesome benchmarks, very nice indeed.
Not all do. Litespeed has a PHP SAPI module, and is very lightweight compared to Apache. Bonus, it can read and use Apache configs.
I’ve been hearing good things about the Cherokee webserver as well. I haven’t used it myself, but while you’re trying out webservers, you might as well put it on your list. I would like to know what you decide in the end though. I always go with Apache, but that’s probably simply because I know that the best.
I found that the only people who recommend Apache as a web server are the people who never tried Lighttpd or Nginx. I think this is true, I used to be one of them too, I would always recommend Apache. Apache is pretty easy to configure, it’s very mature and stable, has tons of custom modules you can find, this is true. It’s perfect if you want to serve images or any type of static files, but mod_php has severe limitations in the throughput. If you don’t need to serve more than about 100 clients at the same time, then it’s fine, but if you plan on ever serving 500 or even 5000 simultaneous connections, then Apache just cannot do this with mod_php. It can do this when started in worker mode, but php canot work with worker mode because it’s not thread safe, so you have to use prefork mode and that’s where the problem lies.
Every connection to Apache, even when to get a simple image or javascript or css file will have to load mod_php anyway, that’s not lightweigh at all.
There is of cause a way to no use mod_php at all, use apache in worker mode and use php as fastcgi. But then why use Apache at all when you can use Lighttpd which uses less memory than Apache. Lighttpd and Nginx both use php as fastcgi. It’s a littly extra effort to setup, you have to startup your php processes separately before you startup the web server, have to make sure your startup script on Linux starts up php processes first. And of cause another thing is that Lighttpd uses non-blocking IO.
Both Lighttpd and Nginx are more difficult to configure than Apache, Nginx is probably more difficult than Lighttpd.
That’s odd - I’ve had used Apache for over 7 years before I switched to nginx and never looked back. I’ve found nginx configuration extremely easy and just common sense, with syntax similar to a programming language.
I would also recommend nginx to anyone - I use it with both small and big sites and it’s simply amazing how fast it is and how few resources it needs to be so.
In my case, switching to fastcgi and rewriting the .htaccess rules was a breeze.
I was an Apache junkie as well and would install/require it on any server I was working on. It was nginx that immediately showed me how Apache actually sucked (in both performance and configuration)