I dont think they usually use it as the web server, as they need some scripting not static pages only. The smallest server I know of that can do cgi is webfsd).
This my defacto, PHP is installed on all the Linux servers I manage, mostly Debian/Ubuntu with DotDeb repos. You could probably get nc to pipe the output of php-cli for older PHP installs.
I remember trying to write a web server that can respond to requests in bash, several years ago. Since it didn't have sockets support that part was going to be handled by netcat. The problem I ended up with was that bash couldn't read and write to the same pipe. The mkfifo solution was the closest that I got to. It turns out that ksh was perfectly capable of reading and writing to the same pipe at that stage. Not long after I got stuck with bash, awk started to support sockets so I used that. Then bash started to support sockets, and many more features, so I suspect it's possible to write a solution in bash now that doesn't need netcat, but might still need a fifo.
68 comments
[ 3.1 ms ] story [ 131 ms ] threadCould be an OS-dependent thing. I'm using OS X.
int_cmd(){exit 1;}trap 'int_cmd' 2;
Web speech API: http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-...
http://php.net/manual/en/features.commandline.webserver.php
Unless the specified 'index.html' is only readable by root, you don't have to be root to run that.
Only the low ports are restricted from regular users.
http://www.home.unix-ag.org/simon/woof.html
Works even in an initramfs, and in some embedded systems. Serves up the current directory, and you can even have CGI scripts in cgi-bin.
* Side note: if it is, make sure your router manufacturer provides the GPL source release.
netcat's cool, but the post could've gone a bit further. If it's an intro "how to do this", maybe explain the moving parts for beginners?
ruby -run -e httpd . -p 5000
http://stackoverflow.com/questions/3940046/can-i-use-netcat-... seems to have a basic example.
while true; sudo /usr/sbin/apachectl start; break; done;
That's not what I would call a "server".