Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script which generates a daily report which I want to serve to the so called general public. The problem is I don't want to add to my headaches maintance of a http server (e.x. apache) with all the configurations and security implications.

Is there a dead simple solution for serving one small html page without the effort of configuring a full blown http server?

share|improve this question
See answer stackoverflow.com/a/4994745 in question One line ftp server in python on Stack Overflow. – manatwork Feb 20 '12 at 11:04
Why not just use netcat? – Dylan Mar 12 at 19:32

14 Answers 14

up vote 6 down vote accepted

Yes, nweb:


To compile nweb.c:

gcc -O -DLINUX nweb.c -o nweb
share|improve this answer

python -m SimpleHTTPServer should do it.

share|improve this answer
Or the Python 3 equivalent: python3 -m http.server – Eliran Malka Feb 14 '14 at 21:05
You can optionally specify a port number like this: python3 -m http.server 1337. You can't specify which IP to bind to as far as I can tell. Note: To listen to port 80 you must have root privileges, e.g.: sudo python3 -m http.server 80 – Hubro Oct 30 '14 at 10:49
This one is nice but it has an issue with redirecting to an URL with a trailing slash added. That's why I prefer the twistd version: twistd -n web -p 8000 --path . – Greg Dubicki Jul 14 '15 at 8:49

Use node.js , fast and lightweight.


just use simple nc netcat command to start a quick webserver on a port and serve the content of a file including the server response headers.

Reference from Wikipedia:


{ echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat some.file; } | nc -l -p 8080
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l -p 8080
share|improve this answer
A bare node.js process with only the interactive shell running takes 15MB (7.5 is shared) of RAM. And then you have to run the HTTP server inside it. It is funny that people see it as lightweight. ;-) – jpc Mar 2 '12 at 14:00
yeah I consider it light weight, you can scale well with such less memory footprint. Please read thecodinghumanist.com/blog/archives/2011/5/6/… However, if you find it cumbersome to use node.js, then the simple netcat utility serves the short lived purpose well. – Nikhil Mulley Mar 2 '12 at 15:28
You are of course right if you compare node with Apache but what I found amusing was how node looks when compared to cr.yp.to/publicfile.html or something similar. :) – jpc Mar 6 '12 at 10:54
hmmmmm.. ok ;-) – Nikhil Mulley Mar 13 '12 at 5:16

Since version 5.4.0 PHP also has a built-in web server:

php -S localhost:8000
share|improve this answer
Wow that was easy and helpful! – Michael-O May 16 '15 at 19:08
This one is really nice if you want to test php-scripts locally. – erik Jul 27 '15 at 9:51

There is a Big list of http static server one-liners:

To get on this list, a solution must:

  1. serve static files using your current directory (or a specified directory) as the server root
  2. be able to be run with a single, one line command (dependencies are fine if they're a one-time thing)
  3. serve basic file types (html, css, js, images) with proper mime types, require no configuration (from files or otherwise) beyond the command itself (no framework-specific servers, etc)
  4. must run, or have a mode where it can run, in the foreground (i.e. no daemons)

For example:

  • Twisted (Python)

    twistd -n web -p 8000 --path . 
  • Erlang:

    erl -s inets -eval 'inets:start(httpd,[{server_name,"NAME"},{document_root, "."},{server_root, "."},{port, 8000},{mime_types,[{"html","text/html"},{"htm","text/html"},{"js","text/javascript"},{"css","text/css"},{"gif","image/gif"},{"jpg","image/jpeg"},{"jpeg","image/jpeg"},{"png","image/png"}]}]).'
  • Plack (Perl)

    cpan Plack
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");' -p 8000
  • webfs

    webfsd -F -p 8000
share|improve this answer

Node has a simple, fast, light HTTP server module. To install:

sudo npm install http-server -g

(Assuming you have node and npm already installed.)

To run it, using the current directory as the website root:


This creates a server on

share|improve this answer

Try using SimpleHTTPServer in Python.

mkdir ~/public_html
command_to_generate_output > ~/public_html/output.txt

(cd ~/public_html; python -c 'import SimpleHTTPServer,BaseHTTPServer; BaseHTTPServer.HTTPServer(("", 8080), SimpleHTTPServer.SimpleHTTPRequestHandler).serve_forever()')

The first two lines are setup for the web server. The last line creates a simple web server, opened on port 8080, which only serves files from ~/public_html. If only one file is in that directory, then only that is exposed: http://localhost:8080/output.txt.

share|improve this answer
that's what i use, just copy the lastline and paste it on a .py file, then run it with python (or make it executable). Keep in mind that you have to run with python 2.x interpreter. – Hanan N. Feb 20 '12 at 21:40

Oldschool Ruby WEBrick HTTP server:

#!/usr/bin/env ruby

require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000,
                                 :DocumentRoot => '~/webrickroot')

# stop server with Ctrl-C
trap('INT') { server.stop }

Make sure to modify the DocumentRoot for your setup. See also this.

share|improve this answer

Simple Ruby one liner to serve a directory:

ruby -run -e httpd . -p 8080
share|improve this answer

Another option would be to install lighttpd. Following are suggested steps to install lighttpd on a Unbuntu 12.04 LTS.

apt-get update
apt-get upgrade --show-upgraded
apt-get install lighttpd
/etc/lighttpd/lighttpd.conf (Edit to add server.port)
server.port = "8080"

Note: Documentroot is where all web accessible files will be places. The location is /var/wwww

The above step will install a basic lighttpd web server. For more information refer the following references


share|improve this answer

./devd -o -a -P devd:devd .

  • -o opens url in browser
  • -a for all interfaces
  • -P auth user/pass
  • . serve files in same directory


share|improve this answer

SFK worth mentioning here


an excellent multipurpose tool with no dependencies

available in both deb and rpm flavours

sfk httpserv -port 1234

will serve current directory

sfk httpserv -port 1234 -rw

will also allow file uploading

share|improve this answer

You can piggy back on xinetd. Put the following config file into /etc/xinetd.d/ and service xinetd reload:

service http
  flags = REUSE IPv4
  protocol = tcp
  socket_type = stream
  port = 80
  wait = no
  user = nobody
  server = /bin/echo
  server_args = -e HTTP/1.0 301 Moved Permanently\nContent-Length: 0\nLocation: https://goo.gl/\n\n
  disable = no

Works for my redirecting purposes:

# wget
--2016-04-04 22:56:20--
Connecting to connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://goo.gl/ [following]
share|improve this answer

Simple netcat example to put in bash script:

while true ; do nc -l 80 <index.html ; done 
share|improve this answer
That entirely fails to speak HTTP. – derobert Aug 6 '14 at 11:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.